From 34723087fe79349607e3128707f0739e5e230a77 Mon Sep 17 00:00:00 2001 From: xunchang Date: Mon, 22 Apr 2019 15:32:17 -0700 Subject: matches_locale no longer accept empty locales in the png file The legacy png files have an empty line in the end. And the recovery used to match any missing locale, e.g. "he" with that line and gets an empty image. Since the empty image is barely useful, we should just error out and fall back to the default locale. This reversed the unit test check added in d17a6885253da909e376ba5ca5084f5281f3557c Bug: 128934634 Test: run locale test with "he" and legacy images, recovery reports error and doesn't crash even without default locale fall back Change-Id: Ibdb7dd0b42348de5e392c834cce67ff02be85c24 --- minui/resources.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'minui/resources.cpp') diff --git a/minui/resources.cpp b/minui/resources.cpp index 53c932bff..00d36d5fb 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -347,6 +347,10 @@ bool matches_locale(const std::string& prefix, const std::string& locale) { // match the locale string without the {script} section. // For instance, prefix == "en" matches locale == "en-US", prefix == "sr-Latn" matches locale // == "sr-Latn-BA", and prefix == "zh-CN" matches locale == "zh-Hans-CN". + if (prefix.empty()) { + return false; + } + if (android::base::StartsWith(locale, prefix)) { return true; } -- cgit v1.2.3