diff options
author | Eike Rathke <erack@redhat.com> | 2013-09-04 19:17:41 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-09-04 19:54:25 +0200 |
commit | 77682c94993193604699079a9325a6dcb32bf965 (patch) | |
tree | 1c411d68a362f3d54427fb45e68cb44d25ad9dfd /i18npool/source/localedata/LocaleNode.cxx | |
parent | e2da56a909ec435e3293da910ec605923a7206ee (diff) |
better error-checking for Language,Country,Variant
Change-Id: I4e4f896ca9af8be7118fc868d57f9e2fa6102d74
Diffstat (limited to 'i18npool/source/localedata/LocaleNode.cxx')
-rw-r--r-- | i18npool/source/localedata/LocaleNode.cxx | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx index 4c49121ed1cf..1c654b073329 100644 --- a/i18npool/source/localedata/LocaleNode.cxx +++ b/i18npool/source/localedata/LocaleNode.cxx @@ -340,25 +340,37 @@ void LCInfoNode::generateCode (const OFileWriter &of) const const LocaleNode * countryNode = findNode("Country"); const LocaleNode * variantNode = findNode("Variant"); + OUString aLanguage; + if (languageNode) { - writeParameterCheckLen( of, "langID", languageNode->getChildAt(0), 2, -1); + aLanguage = languageNode->getChildAt(0)->getValue(); + if (!(aLanguage.getLength() == 2 || aLanguage.getLength() == 3)) + incErrorStr( "langID not 2-3 characters", aLanguage); + of.writeParameter("langID", aLanguage); of.writeParameter("langDefaultName", languageNode->getChildAt(1)->getValue()); } else incError( "No Language node."); if (countryNode) { - of.writeParameter("countryID", countryNode->getChildAt(0)->getValue()); + OUString aCountry( countryNode->getChildAt(0)->getValue()); + if (!(aCountry.isEmpty() || aCountry.getLength() == 2)) + incErrorStr( "countryID not empty or more than 2 characters", aCountry); + of.writeParameter("countryID", aCountry); of.writeParameter("countryDefaultName", countryNode->getChildAt(1)->getValue()); } else incError( "No Country node."); if (variantNode) { - of.writeParameter("Variant", variantNode->getValue()); - fprintf( stderr, "Warning: %s\n", - "Variants are not supported by application."); + // If given Variant must be at least ll-Ssss and language must be 'qlt' + OUString aVariant( variantNode->getValue()); + if (!(aVariant.isEmpty() || (aVariant.getLength() >= 7 && aVariant.indexOf('-')))) + incErrorStr( "invalid Variant", aVariant); + if (!(aVariant.isEmpty() || aLanguage == "qlt")) + incErrorStrStr( "Variant '%s' given but Language '%s' is not 'qlt'", aVariant, aLanguage); + of.writeParameter("Variant", aVariant); } else of.writeParameter("Variant", OUString()); |