summaryrefslogtreecommitdiff
path: root/i18nutil
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2015-11-05 17:22:42 +0300
committerEike Rathke <erack@redhat.com>2015-11-05 18:17:40 +0000
commitc93db073425e61907a290f3f5826c0f79f310275 (patch)
tree322d185551e467abdbf11edd2657984ed19ba341 /i18nutil
parentdd971d008780186c88cc33df3610ed8cc9f0a2f4 (diff)
related tdf#73691 - prevent AltX creating control characters
Do nothing for numbers 0x00 - 0x1f. Change-Id: Idda596e735c464b97dc3624253ebbea86933ff2c Reviewed-on: https://gerrit.libreoffice.org/19654 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'i18nutil')
-rw-r--r--i18nutil/source/utility/unicode.cxx16
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();
}