diff options
author | Michael Stahl <mstahl@redhat.com> | 2018-02-28 13:49:14 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2018-03-01 20:58:27 +0100 |
commit | 0a1d5af2a18d6a062c45d65689fbce619922dcc8 (patch) | |
tree | ddfd509b1b97283135f422169fa04f83a86971d7 /sax/source/tools/fastserializer.cxx | |
parent | 700ed27678d688b1afdb4d1759dcd4b078898a3a (diff) |
tdf#115429 sax: assert if exporting an invalid XML attribute/element
Add a cheap check for this in both SaxWriter and FastSaxSerializer
so we can find such bugs earlier, e.g. with the weekly crashtesting.
Don't do a correct check but a cheap & fast one, let's ignore
non-ASCII characters for now as the only filter with such is UOF
and that is implemented with XSLT, not this sax code.
Change-Id: I4db8f70ffb23684d4cb4211468519edd6c7c465f
Reviewed-on: https://gerrit.libreoffice.org/50507
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sax/source/tools/fastserializer.cxx')
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 6257853a64a8..9356f3e081d1 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -270,11 +270,18 @@ namespace sax_fastparser { void FastSaxSerializer::writeId( ::sal_Int32 nElement ) { if( HAS_NAMESPACE( nElement ) ) { - writeBytes(mxFastTokenHandler->getUTF8Identifier(NAMESPACE(nElement))); + auto const Namespace(mxFastTokenHandler->getUTF8Identifier(NAMESPACE(nElement))); + assert(Namespace.getLength() != 0); + writeBytes(Namespace); writeBytes(sColon, N_CHARS(sColon)); - writeBytes(mxFastTokenHandler->getUTF8Identifier(TOKEN(nElement))); - } else - writeBytes(mxFastTokenHandler->getUTF8Identifier(nElement)); + auto const Element(mxFastTokenHandler->getUTF8Identifier(TOKEN(nElement))); + assert(Element.getLength() != 0); + writeBytes(Element); + } else { + auto const Element(mxFastTokenHandler->getUTF8Identifier(nElement)); + assert(Element.getLength() != 0); + writeBytes(Element); + } } #ifdef DBG_UTIL |