* [gentoo-dev] [PATCH] python-utils-r1.eclass: python_export_utf8_locale(), ensure sane locale
@ 2015-11-15 9:21 Michał Górny
2015-11-28 19:10 ` Michał Górny
0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2015-11-15 9:21 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
Ensure that the locale selected by python_export_utf8_locale() conforms
to POSIX-ish case conversions. Otherwise, we may accidentally force
a locale that will break random ebuilds and programs.
---
eclass/python-utils-r1.eclass | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 6ff1dd1..5e3338f 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1141,6 +1141,24 @@ python_fix_shebang() {
done
}
+# @FUNCTION: _python_check_locale_sanity
+# @USAGE: <locale>
+# @RETURN: 0 if sane, 1 otherwise
+# @DESCRIPTION:
+# Check whether the specified locale sanely maps between lowercase
+# and uppercase ASCII characters.
+_python_check_locale_sanity() {
+ local -x LC_CTYPE=${1}
+ local IFS=
+
+ local lc=( {a..z} )
+ local uc=( {A..Z} )
+ local input=${lc[*]}${uc[*]}
+
+ local output=$(tr '[:lower:][:upper:]' '[:upper:][:lower:]' <<<"${input}")
+ [[ ${output} == "${uc[*]}${lc[*]}" ]]
+}
+
# @FUNCTION: python_export_utf8_locale
# @RETURN: 0 on success, 1 on failure.
# @DESCRIPTION:
@@ -1165,8 +1183,10 @@ python_export_utf8_locale() {
for lang in ${locales}; do
if [[ $(LC_CTYPE=${lang} locale charmap 2>/dev/null) == UTF-8 ]]; then
- export LC_CTYPE=${lang}
- return 0
+ if _python_check_locale_sanity "${lang}"; then
+ export LC_CTYPE=${lang}
+ return 0
+ fi
fi
done
--
2.6.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH] python-utils-r1.eclass: python_export_utf8_locale(), ensure sane locale
2015-11-15 9:21 [gentoo-dev] [PATCH] python-utils-r1.eclass: python_export_utf8_locale(), ensure sane locale Michał Górny
@ 2015-11-28 19:10 ` Michał Górny
2015-12-18 1:23 ` Tyler Pohl
0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2015-11-28 19:10 UTC (permalink / raw
To: gentoo-dev; +Cc: python
[-- Attachment #1: Type: text/plain, Size: 491 bytes --]
On Sun, 15 Nov 2015 10:21:51 +0100
Michał Górny <mgorny@gentoo.org> wrote:
> Ensure that the locale selected by python_export_utf8_locale() conforms
> to POSIX-ish case conversions. Otherwise, we may accidentally force
> a locale that will break random ebuilds and programs.
> ---
> eclass/python-utils-r1.eclass | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
Merged.
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH] python-utils-r1.eclass: python_export_utf8_locale(), ensure sane locale
2015-11-28 19:10 ` Michał Górny
@ 2015-12-18 1:23 ` Tyler Pohl
2015-12-18 2:07 ` Michael Orlitzky
0 siblings, 1 reply; 4+ messages in thread
From: Tyler Pohl @ 2015-12-18 1:23 UTC (permalink / raw
To: gentoo development
[-- Attachment #1: Type: text/plain, Size: 732 bytes --]
Please reomove tylerapohl@gmail.com from the mailing list. Or please let
me know how to get this done.
On Sat, Nov 28, 2015 at 11:10 AM, Michał Górny <mgorny@gentoo.org> wrote:
> On Sun, 15 Nov 2015 10:21:51 +0100
> Michał Górny <mgorny@gentoo.org> wrote:
>
> > Ensure that the locale selected by python_export_utf8_locale() conforms
> > to POSIX-ish case conversions. Otherwise, we may accidentally force
> > a locale that will break random ebuilds and programs.
> > ---
> > eclass/python-utils-r1.eclass | 24 ++++++++++++++++++++++--
> > 1 file changed, 22 insertions(+), 2 deletions(-)
>
> Merged.
>
> --
> Best regards,
> Michał Górny
> <http://dev.gentoo.org/~mgorny/>
>
--
Tyler Pohl
[-- Attachment #2: Type: text/html, Size: 1388 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH] python-utils-r1.eclass: python_export_utf8_locale(), ensure sane locale
2015-12-18 1:23 ` Tyler Pohl
@ 2015-12-18 2:07 ` Michael Orlitzky
0 siblings, 0 replies; 4+ messages in thread
From: Michael Orlitzky @ 2015-12-18 2:07 UTC (permalink / raw
To: gentoo-dev
On 12/17/2015 08:23 PM, Tyler Pohl wrote:
> Please reomove tylerapohl@gmail.com <mailto:tylerapohl@gmail.com> from
> the mailing list. Or please let me know how to get this done.
>
You are doing too much work, Michał.
To unsubscribe, send a message to the address contained in the
List-Unsubscribe header of this (and ever other) list message:
List-Unsubscribe: <mailto:gentoo-dev+unsubscribe@lists.gentoo.org>
See also,
https://www.gentoo.org/get-involved/mailing-lists/instructions.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-18 2:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-15 9:21 [gentoo-dev] [PATCH] python-utils-r1.eclass: python_export_utf8_locale(), ensure sane locale Michał Górny
2015-11-28 19:10 ` Michał Górny
2015-12-18 1:23 ` Tyler Pohl
2015-12-18 2:07 ` Michael Orlitzky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox