summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-06-12 13:01:04 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-06-12 18:31:47 +0200
commit90d4b93c5a7e25498dce949ac6fd2e33d53b74af (patch)
treebe1a26397b48bc3f92d42f75951c2d86cc89d524 /unotools
parent55eeffe768c6a80c97ee4f2a58fb467872ddeb1d (diff)
crashtesting: forum-mso-de-92960 GetEnglishSearchFontName varying results
depending on if it's called once, or twice on the input string. The first converts from Full-Width Characters to equivalent lower ASCII range with non letters retained. And then the second iteration would convert to lower case ASCII with non letters filtered out. Presumably the intention is the Full-Width case should get directly to the same results as multiple calls. Change-Id: Idba4ebe04c907c160ee53abf6d5551550da032dd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135678 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/misc/fontdefs.cxx43
1 files changed, 20 insertions, 23 deletions
diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx
index 44147ffd0927..49f0d09c65cb 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -227,20 +227,24 @@ OUString StripScriptFromName(const OUString& _aName)
}
//return true if the character is stripped from the string
-static bool toOnlyLowerAscii(sal_Unicode c, OUStringBuffer &rName, sal_Int32 nIndex, sal_Int32& rLen)
+static bool toOnlyLowerAsciiOrStrip(sal_Unicode c, OUStringBuffer &rName, sal_Int32 nIndex, sal_Int32& rLen)
{
- // To Lowercase-Ascii
- if ( (c >= 'A') && (c <= 'Z') )
+ // not lowercase Ascii
+ if (c < 'a' || c > 'z')
{
- c += 'a' - 'A';
- rName[nIndex] = c;
- }
- else if( ((c < '0') || (c > '9')) && (c != ';') && (c != '(') && (c != ')') ) // not 0-9, semicolon, or brackets
- {
- // Remove white spaces and special characters
- rName.remove(nIndex, 1);
- rLen--;
- return true;
+ // To Lowercase-Ascii
+ if ( (c >= 'A') && (c <= 'Z') )
+ {
+ c += 'a' - 'A';
+ rName[nIndex] = c;
+ }
+ else if( ((c < '0') || (c > '9')) && (c != ';') && (c != '(') && (c != ')') ) // not 0-9, semicolon, or brackets
+ {
+ // Remove white spaces and special characters
+ rName.remove(nIndex, 1);
+ rLen--;
+ return true;
+ }
}
return false;
}
@@ -273,12 +277,9 @@ OUString GetEnglishSearchFontName(std::u16string_view rInName)
if ( (c >= 0xFF00) && (c <= 0xFF5E) )
{
c -= 0xFF00-0x0020;
- // Upper to Lower
- if ( (c >= 'A') && (c <= 'Z') )
- c += 'a' - 'A';
-
rName[ i ] = c;
-
+ if (toOnlyLowerAsciiOrStrip(c, rName, i, nLen))
+ continue;
}
else
{
@@ -286,12 +287,8 @@ OUString GetEnglishSearchFontName(std::u16string_view rInName)
bNeedTranslation = true;
}
}
- // not lowercase Ascii
- else if ( (c < 'a') || (c > 'z') )
- {
- if (toOnlyLowerAscii(c, rName, i, nLen))
- continue;
- }
+ else if (toOnlyLowerAsciiOrStrip(c, rName, i, nLen))
+ continue;
i++;
}