i18npool/inc/i18npool/lang.h | 1 + i18npool/inc/i18npool/languagetag.hxx | 6 ++++-- i18npool/qa/cppunit/test_languagetag.cxx | 20 ++++++++++++++++++++ i18npool/source/isolang/isolang.cxx | 1 + i18npool/source/isolang/mslangid.cxx | 9 +++++---- i18npool/source/languagetag/languagetag.cxx | 9 +++++++-- svl/source/numbers/zforfind.hxx | 4 ++++ 7 files changed, 42 insertions(+), 8 deletions(-)
New commits: commit d526e48912deeb44061ff570d715c31ca45f77b8 Author: Eike Rathke <er...@redhat.com> Date: Fri Apr 5 14:41:46 2013 +0200 resolved fdo#63161 out of bounds string access Introduced with c7709b460394283fd5b1d2779b6af3585f80a991 String to OUString where previous String::GetChar() handled this. Change-Id: I9253df1af7498e2d7a8ea8077ec6b369697ad44e diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx index 412e189..dadde5c 100644 --- a/svl/source/numbers/zforfind.hxx +++ b/svl/source/numbers/zforfind.hxx @@ -218,6 +218,10 @@ private: const OUString& rString, sal_Int32 nPos ) { + if (rWhat.isEmpty() || rString.getLength() <= nPos) + { + return false; + } // mostly used with one character if ( rWhat[ 0 ] != rString[ nPos ] ) { commit babbd149aa9b2b5a28c55cb38fbbe24586bf8e22 Author: Eike Rathke <er...@redhat.com> Date: Thu Apr 4 21:27:53 2013 +0200 added the dreaded jolly joker Change-Id: I1bd840391496daab2cfe32af6ac00e98de3ed72e diff --git a/i18npool/inc/i18npool/lang.h b/i18npool/inc/i18npool/lang.h index e3643fc..81a6d87 100644 --- a/i18npool/inc/i18npool/lang.h +++ b/i18npool/inc/i18npool/lang.h @@ -555,6 +555,7 @@ typedef unsigned short LanguageType; #define LANGUAGE_USER_YOMBE_CONGO 0x8284 /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_USER_YOMBE)) */ #define LANGUAGE_USER_SIDAMA 0x0685 +#define LANGUAGE_USER_PRIV_JOKER 0xFFEB /* privateuse "*" (sic! bad! nasty!), primary 0x3eb, sub 0x3f */ #define LANGUAGE_USER_PRIV_COMMENT 0xFFEC /* privateuse "x-comment", primary 0x3ec, sub 0x3f */ #define LANGUAGE_USER_PRIV_DEFAULT 0xFFED /* privateuse "x-default", primary 0x3ed, sub 0x3f */ #define LANGUAGE_USER_PRIV_NOTRANSLATE 0xFFEE /* privateuse "x-no-translate" (sic!), primary 0x3ee, sub 0x3f */ diff --git a/i18npool/inc/i18npool/languagetag.hxx b/i18npool/inc/i18npool/languagetag.hxx index 0bba7a1..c3d6055 100644 --- a/i18npool/inc/i18npool/languagetag.hxx +++ b/i18npool/inc/i18npool/languagetag.hxx @@ -376,7 +376,8 @@ private: { EXTRACTED_NONE, EXTRACTED_LSC, - EXTRACTED_X + EXTRACTED_X, + EXTRACTED_X_JOKER }; /** Of a simple language tag of the form lll[-Ssss][-CC] (i.e. one that @@ -385,7 +386,8 @@ private: Does not check case or content! @return EXTRACTED_LSC if simple tag was detected, EXTRACTED_X if x-... - privateuse tag was detected, else EXTRACTED_NONE. + privateuse tag was detected, EXTRACTED_X_JOKER if "*" joker was + detected, else EXTRACTED_NONE. */ static Extraction simpleExtract( const OUString& rBcp47, OUString& rLanguage, diff --git a/i18npool/qa/cppunit/test_languagetag.cxx b/i18npool/qa/cppunit/test_languagetag.cxx index 227be20..4e57b39 100644 --- a/i18npool/qa/cppunit/test_languagetag.cxx +++ b/i18npool/qa/cppunit/test_languagetag.cxx @@ -232,6 +232,26 @@ void TestLanguageTag::testAllTags() CPPUNIT_ASSERT( xfoobar.getLanguageType() == LANGUAGE_SYSTEM ); } + // '*' the dreaded jolly joker is a "privateuse" known "locale" + { + OUString s_joker( "*" ); + LanguageTag joker( s_joker ); + lang::Locale aLocale = joker.getLocale(); + CPPUNIT_ASSERT( joker.getBcp47() == s_joker ); + CPPUNIT_ASSERT( aLocale.Language == "qlt" ); + CPPUNIT_ASSERT( aLocale.Country == "" ); + CPPUNIT_ASSERT( aLocale.Variant == "*" ); + CPPUNIT_ASSERT( joker.getLanguageType() == LANGUAGE_USER_PRIV_JOKER ); + + joker.reset( LANGUAGE_USER_PRIV_JOKER ); + aLocale = joker.getLocale(); + CPPUNIT_ASSERT( joker.getBcp47() == s_joker ); + CPPUNIT_ASSERT( aLocale.Language == "qlt" ); + CPPUNIT_ASSERT( aLocale.Country == "" ); + CPPUNIT_ASSERT( aLocale.Variant == "*" ); + CPPUNIT_ASSERT( joker.getLanguageType() == LANGUAGE_USER_PRIV_JOKER ); + } + // test reset() methods { LanguageTag aTag( LANGUAGE_DONTKNOW ); diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx index e41d228..17a8033 100644 --- a/i18npool/source/isolang/isolang.cxx +++ b/i18npool/source/isolang/isolang.cxx @@ -643,6 +643,7 @@ static IsoLangOtherEntry const aImplPrivateUseEntries[] = { LANGUAGE_USER_PRIV_NOTRANSLATE, "x-no-translate" }, //! not BCP47 but legacy in .xcu configmgr { LANGUAGE_USER_PRIV_DEFAULT, "x-default" }, { LANGUAGE_USER_PRIV_COMMENT, "x-comment" }, + { LANGUAGE_USER_PRIV_JOKER, "*" }, //! not BCP47 but transferable in configmgr { LANGUAGE_DONTKNOW, NULL } // marks end of table }; diff --git a/i18npool/source/isolang/mslangid.cxx b/i18npool/source/isolang/mslangid.cxx index 6afde62..12cf5a3 100644 --- a/i18npool/source/isolang/mslangid.cxx +++ b/i18npool/source/isolang/mslangid.cxx @@ -149,8 +149,8 @@ void MsLangId::Conversion::convertLanguageToLocale( LanguageType nLang, rLocale.Variant = OUString(); convertLanguageToIsoNames( nLang, rLocale.Language, rLocale.Country); /* FIXME: this x-... is temporary until conversion will be moved up to - * LanguageTag */ - if (rLocale.Language.startsWith( "x-")) + * LanguageTag. Also handle the nasty "*" joker as privateuse. */ + if (rLocale.Language.startsWith( "x-") || (rLocale.Language == "*")) { rLocale.Variant = rLocale.Language; rLocale.Language = "qlt"; @@ -186,8 +186,9 @@ LanguageType MsLangId::Conversion::convertLocaleToLanguage( return LANGUAGE_SYSTEM; /* FIXME: this x-... is temporary until conversion will be moved up to - * LanguageTag */ - LanguageType nRet = ((!rLocale.Variant.isEmpty() && rLocale.Variant.startsWithIgnoreAsciiCase( "x-")) ? + * LanguageTag. Also handle the nasty "*" joker as privateuse. */ + LanguageType nRet = ((!rLocale.Variant.isEmpty() && + (rLocale.Variant.startsWithIgnoreAsciiCase( "x-") || (rLocale.Variant == "*"))) ? convertPrivateUseToLanguage( rLocale.Variant) : convertIsoNamesToLanguage( rLocale.Language, rLocale.Country)); if (nRet == LANGUAGE_DONTKNOW) diff --git a/i18npool/source/languagetag/languagetag.cxx b/i18npool/source/languagetag/languagetag.cxx index 16b81d8..c93943d 100644 --- a/i18npool/source/languagetag/languagetag.cxx +++ b/i18npool/source/languagetag/languagetag.cxx @@ -430,7 +430,7 @@ bool LanguageTag::canonicalize() // locale. OUString aLanguage, aScript, aCountry; Extraction eExt = simpleExtract( maBcp47, aLanguage, aScript, aCountry); - if (eExt == EXTRACTED_LSC || eExt == EXTRACTED_X) + if (eExt != EXTRACTED_NONE) { if (eExt == EXTRACTED_LSC && aScript.isEmpty()) { @@ -1160,7 +1160,12 @@ LanguageTag::Extraction LanguageTag::simpleExtract( const OUString& rBcp47, Extraction eRet = EXTRACTED_NONE; const sal_Int32 nLen = rBcp47.getLength(); const sal_Int32 nHyph1 = rBcp47.indexOf( '-'); - if (nHyph1 == 1 && rBcp47[0] == 'x') // x-... privateuse + if (nLen == 1 && rBcp47[0] == '*') // * the dreaded jolly joker + { + // It's f*d up but we need to recognize this. + eRet = EXTRACTED_X_JOKER; + } + else if (nHyph1 == 1 && rBcp47[0] == 'x') // x-... privateuse { // x-... privateuse tags MUST be known to us by definition. eRet = EXTRACTED_X; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits