Kaydet (Commit) 9107bb35 authored tarafından Caolán McNamara's avatar Caolán McNamara

sanitize strings with invalid high/low surrogate sequences

Change-Id: I9ad1aa651b6971526dd924630fe5606b7632f2dc
üst de4c419c
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
#include <IMark.hxx> #include <IMark.hxx>
#include <unotools/fltrcfg.hxx> #include <unotools/fltrcfg.hxx>
#include <rtl/surrogates.h>
#include <xmloff/odffields.hxx> #include <xmloff/odffields.hxx>
#include <stdio.h> #include <stdio.h>
...@@ -493,6 +494,31 @@ static void lcl_CopyGreaterEight(OUString &rDest, OUString &rSrc, ...@@ -493,6 +494,31 @@ static void lcl_CopyGreaterEight(OUString &rDest, OUString &rSrc,
} }
} }
OUString sanitizeString(const OUString& rString)
{
sal_Int32 i=0;
while (i < rString.getLength())
{
sal_Unicode c = rString[i];
if (isHighSurrogate(c))
{
if (i+1 == rString.getLength() || !isLowSurrogate(rString[i+1]))
{
SAL_WARN("sw.ww8", "Surrogate error: high without low");
return rString.copy(0, i);
}
++i; //skip correct low
}
if (isLowSurrogate(c)) //bare low without preceeding high
{
SAL_WARN("sw.ww8", "Surrogate error: low without high");
return rString.copy(0, i);
}
++i;
}
return rString;
}
bool WW8ListManager::ReadLVL(SwNumFmt& rNumFmt, SfxItemSet*& rpItemSet, bool WW8ListManager::ReadLVL(SwNumFmt& rNumFmt, SfxItemSet*& rpItemSet,
sal_uInt16 nLevelStyle, bool bSetStartNo, sal_uInt16 nLevelStyle, bool bSetStartNo,
std::deque<bool> &rNotReallyThere, sal_uInt16 nLevel, std::deque<bool> &rNotReallyThere, sal_uInt16 nLevel,
...@@ -703,7 +729,7 @@ bool WW8ListManager::ReadLVL(SwNumFmt& rNumFmt, SfxItemSet*& rpItemSet, ...@@ -703,7 +729,7 @@ bool WW8ListManager::ReadLVL(SwNumFmt& rNumFmt, SfxItemSet*& rpItemSet,
// 4. den Nummerierungsstring einlesen: ergibt Prefix und Postfix // 4. den Nummerierungsstring einlesen: ergibt Prefix und Postfix
OUString sNumString(read_uInt16_PascalString(rSt)); OUString sNumString(sanitizeString(read_uInt16_PascalString(rSt)));
// 5. gelesene Werte in Writer Syntax umwandeln // 5. gelesene Werte in Writer Syntax umwandeln
......
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