diff options
author | Eike Rathke <erack@redhat.com> | 2019-05-14 16:32:12 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2019-05-30 19:21:33 +0200 |
commit | 63c4e82c910422f928c8e0bcbb82b6c43d4d5557 (patch) | |
tree | 9eb036a40e2d878e3d43ee57f63ef49690bdee40 /sax/source | |
parent | 1376bb3e44c4b9eb15cf788df04f7cc0bba8cb09 (diff) |
Reintroduce mbXescape that got overaggressively removed
with
commit d4d37662b090cb237585156a47cd8e1f1cbe2656
CommitDate: Fri Oct 12 12:46:45 2018 +0200
loplugin:constfields in reportdesign,sal,sax
which killed also the bGood checking and later because that wasn't
used anymore also the SAL_WARN_IF() was eliminated with
commit 41eeaace84b45c803fff3ebd5ab981f0ad09393b
CommitDate: Mon Oct 29 15:12:26 2018 +0100
loplugin:oncevar
The mbXescape variable will be used, as the TODO said..
Change-Id: I11091379c27cf0222677595eb723b61ad3ebe4e8
Reviewed-on: https://gerrit.libreoffice.org/72302
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sax/source')
-rw-r--r-- | sax/source/tools/fastserializer.cxx | 16 | ||||
-rw-r--r-- | sax/source/tools/fastserializer.hxx | 3 |
2 files changed, 19 insertions, 0 deletions
diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 4a4091438a40..1a422ad8239a 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -59,6 +59,7 @@ namespace sax_fastparser { , mbMarkStackEmpty(true) , mpDoubleStr(nullptr) , mnDoubleStrCapacity(RTL_STR_MAX_VALUEOFDOUBLE) + , mbXescape(true) { rtl_string_new_WithLength(&mpDoubleStr, mnDoubleStrCapacity); mxFastTokenHandler = css::xml::sax::FastTokenHandler::create( @@ -135,6 +136,7 @@ namespace sax_fastparser { return; } + bool bGood = true; const sal_Int32 kXescapeLen = 7; char bufXescape[kXescapeLen+1]; sal_Int32 nNextXescape = 0; @@ -195,6 +197,7 @@ namespace sax_fastparser { } break; default: + if (mbXescape) { // Escape characters not valid in XML 1.0 as // _xHHHH_. A literal "_xHHHH_" has to be @@ -239,10 +242,23 @@ namespace sax_fastparser { * scanning for both encoded sequences and * write as _xHHHH_? */ } +#if OSL_DEBUG_LEVEL > 0 + else + { + if (bGood && invalidChar(pStr[i])) + { + bGood = false; + // The SAL_WARN() for the single character is + // issued in writeBytes(), just gather for the + // SAL_WARN_IF() below. + } + } +#endif writeBytes( &c, 1 ); break; } } + SAL_WARN_IF( !bGood && nLen > 1, "sax", "in '" << OString(pStr,std::min<sal_Int32>(nLen,42)) << "'"); } void FastSaxSerializer::endDocument() diff --git a/sax/source/tools/fastserializer.hxx b/sax/source/tools/fastserializer.hxx index b00ccf0923df..e3aa17a78f91 100644 --- a/sax/source/tools/fastserializer.hxx +++ b/sax/source/tools/fastserializer.hxx @@ -228,6 +228,9 @@ private: rtl_String *mpDoubleStr; sal_Int32 mnDoubleStrCapacity; TokenValueList maTokenValues; + bool mbXescape; ///< whether to escape invalid XML characters as _xHHHH_ in write(const char*,sal_Int32,true) + /* TODO: make that configurable from the outside for + * some specific cases? */ #ifdef DBG_UTIL std::stack<sal_Int32> m_DebugStartedElements; |