summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/qa/unit/test.cxx7
-rw-r--r--configmgr/source/access.cxx12
2 files changed, 13 insertions, 6 deletions
diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx
index 3de93a6672df..7aa2daf6f96d 100644
--- a/configmgr/qa/unit/test.cxx
+++ b/configmgr/qa/unit/test.cxx
@@ -324,6 +324,13 @@ void Test::testLocalizedProperty() {
access->getByHierarchicalName("/org.libreoffice.unittest/localized/*pt") >>= v);
CPPUNIT_ASSERT_EQUAL(OUString("pt-PT"), v);
}
+ {
+ // Make sure a degenerate passed-in "-" locale is handled gracefully:
+ OUString v;
+ CPPUNIT_ASSERT(
+ access->getByHierarchicalName("/org.libreoffice.unittest/localized/*-") >>= v);
+ CPPUNIT_ASSERT_EQUAL(OUString("default"), v);
+ }
}
void Test::testReadCommands()
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index 48d9b46ddc26..9d71c7fa2978 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -68,6 +68,7 @@
#include <com/sun/star/util/ElementChange.hpp>
#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
+#include <comphelper/string.hxx>
#include <comphelper/lok.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <cppu/unotype.hxx>
@@ -1407,12 +1408,11 @@ rtl::Reference< ChildAccess > Access::getChild(OUString const & name) {
// xml:lang attributes, look for the first entry with the same first
// segment as the requested language tag before falling back to
// defaults (see fdo#33638):
- if (aFallbacks.size() > 0)
- locale = aFallbacks[aFallbacks.size() - 1];
- assert(
- !locale.isEmpty() && locale.indexOf('-') == -1 &&
- locale.indexOf('_') == -1);
-
+ auto const i = comphelper::string::indexOfAny(locale, u"-_", 1);
+ if (i != -1) {
+ locale = locale.copy(0, i);
+ }
+ assert(!locale.isEmpty());
std::vector< rtl::Reference< ChildAccess > > children(
getAllChildren());
for (auto const& child : children)