diff options
author | Eike Rathke <erack@redhat.com> | 2020-12-20 19:24:36 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2020-12-20 22:11:08 +0100 |
commit | ff804ebff0c94e8780f01dde80c402afd3a5d208 (patch) | |
tree | 10461aff0454e007e682e9334b70436e906b874c /i18npool | |
parent | 31cd6fd0f3c856a81a03d0229de1c4d10442844f (diff) |
Check Calendar unoid for unknown and duplicates
https://gerrit.libreoffice.org/c/core/+/108015 tried to add
another Gregorian calendar with a made-up "gregorian_en" unoid.
Prevent that already at build time.
Change-Id: Id1bed6bea28b9c80e75b03753cdb367d3160dac1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108055
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/localedata/LocaleNode.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index 3040f3312d42..34c77516cc73 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -22,6 +22,7 @@ #include <algorithm> #include <memory> #include <vector> +#include <map> #include <o3tl/sorted_vector.hxx> #include <rtl/ustrbuf.hxx> @@ -1559,6 +1560,23 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const std::unique_ptr<sal_Int16[]> nbOfGenitiveMonths( new sal_Int16[nbOfCalendars] ); std::unique_ptr<sal_Int16[]> nbOfPartitiveMonths( new sal_Int16[nbOfCalendars] ); std::unique_ptr<sal_Int16[]> nbOfEras( new sal_Int16[nbOfCalendars] ); + + // Known allowed calendar identifiers (unoid) and whether used or not. + // Of course there must be an implementation for new to be added + // identifiers.. see data/locale.dtd + std::map< OUString, bool > aCalendars; + aCalendars["buddhist"] = false; + aCalendars["gengou"] = false; + aCalendars["gregorian"] = false; + aCalendars["hanja"] = false; + aCalendars["hanja_yoil"] = false; + aCalendars["hijri"] = false; + aCalendars["jewish"] = false; + aCalendars["ROC"] = false; + // Not in ODF: + aCalendars["dangi"] = false; + aCalendars["persian"] = false; + sal_Int16 j; sal_Int16 i; bool bHasGregorian = false; @@ -1571,6 +1589,13 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const bool bGregorian = calendarID == "gregorian"; if (!bHasGregorian) bHasGregorian = bGregorian; + auto calIt = aCalendars.find(calendarID); + if (calIt == aCalendars.end()) + incErrorStr( "Error: unknown Calendar unoid: %s\n", calendarID); + else if (calIt->second) + incErrorStr( "Error: duplicate Calendar unoid: %s\n", calendarID); + else + calIt->second = true; str = calNode -> getAttr().getValueByName("default"); of.writeDefaultParameter("Calendar", str, i); |