1 |
Ensure that the locale selected by python_export_utf8_locale() conforms |
2 |
to POSIX-ish case conversions. Otherwise, we may accidentally force |
3 |
a locale that will break random ebuilds and programs. |
4 |
--- |
5 |
eclass/python-utils-r1.eclass | 24 ++++++++++++++++++++++-- |
6 |
1 file changed, 22 insertions(+), 2 deletions(-) |
7 |
|
8 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
9 |
index 6ff1dd1..5e3338f 100644 |
10 |
--- a/eclass/python-utils-r1.eclass |
11 |
+++ b/eclass/python-utils-r1.eclass |
12 |
@@ -1141,6 +1141,24 @@ python_fix_shebang() { |
13 |
done |
14 |
} |
15 |
|
16 |
+# @FUNCTION: _python_check_locale_sanity |
17 |
+# @USAGE: <locale> |
18 |
+# @RETURN: 0 if sane, 1 otherwise |
19 |
+# @DESCRIPTION: |
20 |
+# Check whether the specified locale sanely maps between lowercase |
21 |
+# and uppercase ASCII characters. |
22 |
+_python_check_locale_sanity() { |
23 |
+ local -x LC_CTYPE=${1} |
24 |
+ local IFS= |
25 |
+ |
26 |
+ local lc=( {a..z} ) |
27 |
+ local uc=( {A..Z} ) |
28 |
+ local input=${lc[*]}${uc[*]} |
29 |
+ |
30 |
+ local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}") |
31 |
+ [[ ${output} == "${uc[*]}${lc[*]}" ]] |
32 |
+} |
33 |
+ |
34 |
# @FUNCTION: python_export_utf8_locale |
35 |
# @RETURN: 0 on success, 1 on failure. |
36 |
# @DESCRIPTION: |
37 |
@@ -1165,8 +1183,10 @@ python_export_utf8_locale() { |
38 |
|
39 |
for lang in ${locales}; do |
40 |
if [[ $(LC_CTYPE=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then |
41 |
- export LC_CTYPE=${lang} |
42 |
- return 0 |
43 |
+ if _python_check_locale_sanity "${lang}"; then |
44 |
+ export LC_CTYPE=${lang} |
45 |
+ return 0 |
46 |
+ fi |
47 |
fi |
48 |
done |
49 |
|
50 |
-- |
51 |
2.6.3 |