Kaydet (Commit) 63c4e82c authored tarafından Eike Rathke's avatar Eike Rathke

Reintroduce mbXescape that got overaggressively removed

with

    commit d4d37662
    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 41eeaace
    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: 's avatarEike Rathke <erack@redhat.com>
üst 1376bb3e
...@@ -59,6 +59,7 @@ namespace sax_fastparser { ...@@ -59,6 +59,7 @@ namespace sax_fastparser {
, mbMarkStackEmpty(true) , mbMarkStackEmpty(true)
, mpDoubleStr(nullptr) , mpDoubleStr(nullptr)
, mnDoubleStrCapacity(RTL_STR_MAX_VALUEOFDOUBLE) , mnDoubleStrCapacity(RTL_STR_MAX_VALUEOFDOUBLE)
, mbXescape(true)
{ {
rtl_string_new_WithLength(&mpDoubleStr, mnDoubleStrCapacity); rtl_string_new_WithLength(&mpDoubleStr, mnDoubleStrCapacity);
mxFastTokenHandler = css::xml::sax::FastTokenHandler::create( mxFastTokenHandler = css::xml::sax::FastTokenHandler::create(
...@@ -135,6 +136,7 @@ namespace sax_fastparser { ...@@ -135,6 +136,7 @@ namespace sax_fastparser {
return; return;
} }
bool bGood = true;
const sal_Int32 kXescapeLen = 7; const sal_Int32 kXescapeLen = 7;
char bufXescape[kXescapeLen+1]; char bufXescape[kXescapeLen+1];
sal_Int32 nNextXescape = 0; sal_Int32 nNextXescape = 0;
...@@ -195,6 +197,7 @@ namespace sax_fastparser { ...@@ -195,6 +197,7 @@ namespace sax_fastparser {
} }
break; break;
default: default:
if (mbXescape)
{ {
// Escape characters not valid in XML 1.0 as // Escape characters not valid in XML 1.0 as
// _xHHHH_. A literal "_xHHHH_" has to be // _xHHHH_. A literal "_xHHHH_" has to be
...@@ -239,10 +242,23 @@ namespace sax_fastparser { ...@@ -239,10 +242,23 @@ namespace sax_fastparser {
* scanning for both encoded sequences and * scanning for both encoded sequences and
* write as _xHHHH_? */ * 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 ); writeBytes( &c, 1 );
break; break;
} }
} }
SAL_WARN_IF( !bGood && nLen > 1, "sax", "in '" << OString(pStr,std::min<sal_Int32>(nLen,42)) << "'");
} }
void FastSaxSerializer::endDocument() void FastSaxSerializer::endDocument()
......
...@@ -228,6 +228,9 @@ private: ...@@ -228,6 +228,9 @@ private:
rtl_String *mpDoubleStr; rtl_String *mpDoubleStr;
sal_Int32 mnDoubleStrCapacity; sal_Int32 mnDoubleStrCapacity;
TokenValueList maTokenValues; 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 #ifdef DBG_UTIL
std::stack<sal_Int32> m_DebugStartedElements; std::stack<sal_Int32> m_DebugStartedElements;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment