summaryrefslogtreecommitdiff
path: root/sax/source/fastparser/fastparser.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sax/source/fastparser/fastparser.cxx')
-rw-r--r--sax/source/fastparser/fastparser.cxx25
1 files changed, 23 insertions, 2 deletions
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 0b4137b9e939..49038b8d6357 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -233,6 +233,7 @@ public:
Entity& getEntity() { return *mpTop; }
void parse();
void produce( bool bForceFlush = false );
+ bool m_bIgnoreMissingNSDecl;
private:
bool consume(EventList *);
@@ -619,6 +620,7 @@ FastSaxParserImpl::FastSaxParserImpl( FastSaxParser* ) :
#if 0
mpFront(pFront),
#endif
+ m_bIgnoreMissingNSDecl(false),
mpTop(nullptr)
{
mxDocumentLocator.set( new FastLocatorImpl( this ) );
@@ -668,7 +670,7 @@ sal_Int32 FastSaxParserImpl::GetTokenWithPrefix( const xmlChar* pPrefix, int nPr
break;
}
- if( !nNamespace )
+ if( !nNamespace && !m_bIgnoreMissingNSDecl )
throw SAXException("No namespace defined for " + OUString(XML_CAST(pPrefix),
nPrefixLen, RTL_TEXTENCODING_UTF8), Reference< XInterface >(), Any());
}
@@ -1129,7 +1131,8 @@ void FastSaxParserImpl::callbackStartElement(const xmlChar *localName , const xm
{
if( prefix != nullptr )
{
- sNamespace = OUString( XML_CAST( URI ), strlen( XML_CAST( URI )), RTL_TEXTENCODING_UTF8 );
+ if ( !m_bIgnoreMissingNSDecl || URI != nullptr )
+ sNamespace = OUString( XML_CAST( URI ), strlen( XML_CAST( URI )), RTL_TEXTENCODING_UTF8 );
nNamespaceToken = GetNamespaceToken( sNamespace );
rEvent.msNamespace = OUString( XML_CAST( prefix ), strlen( XML_CAST( prefix )), RTL_TEXTENCODING_UTF8 );
}
@@ -1300,6 +1303,24 @@ FastSaxParser::~FastSaxParser()
{
}
+void SAL_CALL
+FastSaxParser::initialize(css::uno::Sequence< css::uno::Any > const& rArguments)
+ throw (css::uno::RuntimeException, css::uno::Exception, std::exception)
+{
+ if (rArguments.getLength())
+ {
+ OUString str;
+ if ( ( rArguments[0] >>= str ) && "IgnoreMissingNSDecl" == str )
+ mpImpl->m_bIgnoreMissingNSDecl = true;
+ else if ( str == "DoSmeplease" )
+ {
+ //just ignore as this is already immune to billon laughs
+ }
+ else
+ throw IllegalArgumentException();
+ }
+}
+
void FastSaxParser::parseStream( const xml::sax::InputSource& aInputSource )
throw (xml::sax::SAXException, io::IOException,
uno::RuntimeException, std::exception)