[Libreoffice-commits] core.git: sax/source
dante (via logerrit)
logerrit at kemper.freedesktop.org
Mon Dec 7 12:29:32 UTC 2020
sax/source/fastparser/fastparser.cxx | 39 +++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
New commits:
commit 1a6191621a0257c479bdfe24e125c0258d4b3d0d
Author: dante <dante19031999 at gmail.com>
AuthorDate: Wed Dec 2 00:02:45 2020 +0100
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Dec 7 13:28:52 2020 +0100
Adding suppor for &#dddd; and &#xhhhh; on fastparser.
Change-Id: Iacbbe8a77532fe5034ceae286f50a74310f7d2ed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107036
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx
index 662991ff91ba..9b2d9bd97458 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -46,6 +46,7 @@
#include <cassert>
#include <cstring>
#include <libxml/parser.h>
+#include <cstdint>
// Inverse of libxml's BAD_CAST.
#define XML_CAST( str ) reinterpret_cast< const char* >( str )
@@ -1364,16 +1365,50 @@ void FastSaxParserImpl::callbackProcessingInstruction( const xmlChar *target, co
xmlEntityPtr FastSaxParserImpl::callbackGetEntity( const xmlChar *name )
{
+ if( !name )
+ return xmlGetPredefinedEntity(name);
+ const char* dname = XML_CAST(name);
for( size_t i = 0; i < mEntityNames.size(); ++i )
{
- if( mEntityNames[i].compareToAscii(XML_CAST(name)) == 0 )
+ if( mEntityNames[i].compareToAscii(dname) == 0 )
{
return xmlNewEntity( nullptr,
- BAD_CAST(OUStringToOString(mEntityNames[i],RTL_TEXTENCODING_UTF8).getStr()),
+ name,
XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
BAD_CAST(OUStringToOString(mEntityReplacements[i],RTL_TEXTENCODING_UTF8).getStr()));
}
}
+ if ( dname[0] == '#' )
+ {
+ sal_uInt32 cval = 0;
+ int_fast16_t lname = strlen(dname);
+ if( lname < 2 )
+ return xmlGetPredefinedEntity(name);
+ if( dname[1] == 'x' || dname[1] == 'X' )
+ {
+ if( lname < 3 )
+ return xmlGetPredefinedEntity(name);
+ cval = static_cast<sal_uInt32>( strtoul( dname + 2, nullptr, 16 ) );
+ if( cval == 0 )
+ return xmlGetPredefinedEntity(name);
+ OUString vname( &cval, 1 );
+ return xmlNewEntity( nullptr,
+ name,
+ XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
+ BAD_CAST(OUStringToOString(vname,RTL_TEXTENCODING_UTF8).getStr()));
+ }
+ else
+ {
+ cval = static_cast<sal_uInt32>( strtoul( dname + 2, nullptr, 10 ) );
+ if( cval == 0 )
+ return xmlGetPredefinedEntity(name);
+ OUString vname( &cval, 1 );
+ return xmlNewEntity( nullptr,
+ name,
+ XML_INTERNAL_GENERAL_ENTITY, nullptr, nullptr,
+ BAD_CAST(OUStringToOString(vname,RTL_TEXTENCODING_UTF8).getStr()));
+ }
+ }
return xmlGetPredefinedEntity(name);
}
More information about the Libreoffice-commits
mailing list