cui/source/options/optgdlg.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit cdded98b23698e5e2a5cfffd5638e395098fcc4a
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Sun Oct 23 19:13:15 2022 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Sun Oct 23 20:00:44 2022 +0200

    Related: tdf#147817 prevent date acceptance pattern with numeric ambiguity
    
    i.e. matching input with numeric decinmal separator, like M.D
    
    Change-Id: Ice977b3e92373829cd2f5df7c065d55bc49fc23e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141686
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index d58176ff00eb..7b887b4e6965 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -1719,6 +1719,18 @@ IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, 
weld::Entry&, rEd, void )
                 bool bY, bM, bD;
                 bY = bM = bD = false;
                 bool bSep = true;
+                if (aPat.getLength() == 3)
+                {
+                    // Disallow a pattern that would match a numeric input with
+                    // decimal separator, like M.D
+                    const LanguageType eLang = 
m_xLocaleSettingLB->get_active_id();
+                    const LocaleDataWrapper aLocaleWrapper(( 
LanguageTag(eLang)));
+                    if (    aPat[1] == 
aLocaleWrapper.getNumDecimalSep().toChar()
+                         || aPat[1] == 
aLocaleWrapper.getNumDecimalSepAlt().toChar())
+                    {
+                        bValid = false;
+                    }
+                }
                 for (sal_Int32 i = 0; i < aPat.getLength() && bValid; /*nop*/)
                 {
                     const sal_Int32 j = i;

Reply via email to