diff options
author | Mohammed Abdul Azeem <azeemmysore@gmail.com> | 2016-07-18 13:17:19 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2016-07-19 14:17:15 +0000 |
commit | 3aa52d36824d11b8774de15708fdfcbb93cd9dc3 (patch) | |
tree | da30a99082cdb0d774e5a452344a976abf6a4bb5 /sax/source | |
parent | sc lok: notify other views about selection changes of multiple cells (diff) | |
download | core-3aa52d36824d11b8774de15708fdfcbb93cd9dc3.tar.gz core-3aa52d36824d11b8774de15708fdfcbb93cd9dc3.zip |
GSOC - Handling namespace declaration missing case:
initialization parameter to FastParser will turn off
the namespace declaration missing exception. Test cases
have also been given to verify the same.
Change-Id: I4c3e02c7ad92d50e279f895ced53c78fc8f49b91
Reviewed-on: https://gerrit.libreoffice.org/27278
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sax/source')
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 25 | ||||
-rw-r--r-- | sax/source/fastparser/legacyfastparser.cxx | 5 |
2 files changed, 27 insertions, 3 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) diff --git a/sax/source/fastparser/legacyfastparser.cxx b/sax/source/fastparser/legacyfastparser.cxx index ab673441f914..1c82178d0526 100644 --- a/sax/source/fastparser/legacyfastparser.cxx +++ b/sax/source/fastparser/legacyfastparser.cxx @@ -280,9 +280,12 @@ SaxLegacyFastParser::SaxLegacyFastParser( ) : m_aNamespaceHandler( new Namespace m_xParser->setNamespaceHandler( m_aNamespaceHandler.get() ); } -void SAL_CALL SaxLegacyFastParser::initialize(Sequence< Any > const&/* rArguments */) +void SAL_CALL SaxLegacyFastParser::initialize(Sequence< Any > const& rArguments ) throw (RuntimeException, Exception, exception) { + uno::Reference<lang::XInitialization> const xInit(m_xParser, + uno::UNO_QUERY_THROW); + xInit->initialize( rArguments ); } void SaxLegacyFastParser::parseStream( const InputSource& structSource ) |