diff options
-rw-r--r-- | i18nutil/source/utility/unicode.cxx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/i18nutil/source/utility/unicode.cxx b/i18nutil/source/utility/unicode.cxx index 8b56239550d5..a7d3d4690f1c 100644 --- a/i18nutil/source/utility/unicode.cxx +++ b/i18nutil/source/utility/unicode.cxx @@ -1084,6 +1084,13 @@ bool ToggleUnicodeCodepoint::AllowMoreInput(sal_Unicode uChar) return false; } + // 0 - 1f are control characters. Do not process those. + if( uChar < 0x20 ) + { + mbAllowMoreChars = false; + return false; + } + switch( uChar ) { case 'u': @@ -1117,9 +1124,6 @@ bool ToggleUnicodeCodepoint::AllowMoreInput(sal_Unicode uChar) maInput.insertUtf32(0, uChar); } break; - case 0: - mbAllowMoreChars = false; - break; default: // + already found. Since not U, cancel further input if( mbRequiresU ) @@ -1185,15 +1189,15 @@ OUString ToggleUnicodeCodepoint::StringToReplace() while( nUPlus != -1 ) { nUnicode = sIn.copy(0, nUPlus).toString().toUInt32(16); - //strip out all null or invalid Unicode values - if( !nUnicode || nUnicode > 0x10ffff ) + //prevent creating control characters or invalid Unicode values + if( nUnicode < 0x20 || nUnicode > 0x10ffff ) maInput = sIn.copy(nUPlus); sIn = sIn.copy(nUPlus+2); nUPlus = sIn.indexOf("U+"); } nUnicode = sIn.toString().toUInt32(16); - if( !nUnicode || nUnicode > 0x10ffff ) + if( nUnicode < 0x20 || nUnicode > 0x10ffff ) maInput.truncate().append( sIn[sIn.getLength()-1] ); return maInput.toString(); } |