Commits

Anonymous committed 9b04618

sb136: #i115386# prefer en[-US] over empty xml:lang value, to accomodate existing extensions with bad .xcu content

Comments (0)

Files changed (1)

configmgr/source/childaccess.cxx

             if (!Components::allLocales(locale)) {
                 // Find best match using an adaption of RFC 4647 lookup matching
                 // rules, removing "-" or "_" delimited segments from the end;
-                // defaults are the empty string locale, the "en-US" locale, the
-                // "en" locale, the first child (if any), or a nil value (even
+                // defaults are the "en-US" locale, the "en" locale, the empty
+                // string locale, the first child (if any), or a nil value (even
                 // though it may be illegal for the given property), in that
                 // order:
                 rtl::Reference< ChildAccess > child;
                     while (i > 0 && locale[i] != '-' && locale[i] != '_') {
                         --i;
                     }
+                    if (i == 0) {
+                        break;
+                    }
                     locale = locale.copy(0, i);
                 }
                 if (!child.is()) {
                         child = getChild(
                             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en")));
                         if (!child.is()) {
-                            std::vector< rtl::Reference< ChildAccess > > all(
-                                getAllChildren());
-                            if (!all.empty()) {
-                                child = all.front();
+                            child = getChild(rtl::OUString());
+                            if (!child.is()) {
+                                std::vector< rtl::Reference< ChildAccess > >
+                                    all(getAllChildren());
+                                if (!all.empty()) {
+                                    child = all.front();
+                                }
                             }
                         }
                     }