diff options
author | Eike Rathke <erack@redhat.com> | 2021-07-05 12:06:27 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2021-07-06 11:03:37 +0200 |
commit | a8ef7e49afcc41d6069743ca5c81e7f2b18f4db2 (patch) | |
tree | a95ec2c38407332f8533f4e52cf332534086c6da | |
parent | Resolves: tdf#138432 Use locale's CharClass to parse numeric i18n context (diff) | |
download | core-a8ef7e49afcc41d6069743ca5c81e7f2b18f4db2.tar.gz core-a8ef7e49afcc41d6069743ca5c81e7f2b18f4db2.zip |
Resolves: tdf#143165 Date input must match separator, D,M,Y not part of
Change-Id: Iae464fd0fc6c480b9a16ccb2f8eb635812c6eeff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118408
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 89a3caee73c476133af804d9a0a650e72e711d95)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118422
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | svl/source/numbers/zforfind.cxx | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index edf75a004244..87c64df62c2a 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -1263,6 +1263,17 @@ static bool lcl_IsSignedYearSep( const OUString& rStr, const OUString& rPat, sal } +/** Length of separator usually is 1 but theoretically could be anything. */ +static sal_Int32 lcl_getPatternSeparatorLength( const OUString& rPat, sal_Int32 nPat ) +{ + sal_Int32 nSep = nPat; + sal_Unicode c; + while (nSep < rPat.getLength() && (c = rPat[nSep]) != 'D' && c != 'M' && c != 'Y') + ++nSep; + return nSep - nPat; +} + + bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt ) { if (nAcceptedDatePattern >= -1) @@ -1383,8 +1394,11 @@ bool ImpSvNumberInputScan::IsAcceptedDatePattern( sal_uInt16 nStartPatternAt ) bOk = !IsNum[nNext]; if (bOk) { + const sal_Int32 nSepLen = lcl_getPatternSeparatorLength( rPat, nPat); + // Non-numeric input must match separator exactly to be + // accepted as such. const sal_Int32 nLen = sStrArray[nNext].getLength(); - bOk = (rPat.indexOf( sStrArray[nNext], nPat) == nPat); + bOk = (nLen == nSepLen && rPat.indexOf( sStrArray[nNext], nPat) == nPat); if (bOk) { nPat += nLen - 1; @@ -1503,8 +1517,9 @@ bool ImpSvNumberInputScan::SkipDatePatternSeparator( sal_uInt16 nParticle, sal_I default: if (nNext == nParticle) { + const sal_Int32 nSepLen = lcl_getPatternSeparatorLength( rPat, nPat); const sal_Int32 nLen = sStrArray[nNext].getLength(); - bool bOk = (rPat.indexOf( sStrArray[nNext], nPat) == nPat); + bool bOk = (nLen == nSepLen && rPat.indexOf( sStrArray[nNext], nPat) == nPat); if (!bOk) { bOk = lcl_IsSignedYearSep( sStrArray[nNext], rPat, nPat); |