summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-09-28 20:37:37 -0400
committerMike Frysinger <vapier@gentoo.org>2015-09-28 20:38:38 -0400
commit751d0f79973aa5c2918b386e814aa3eda17df27b (patch)
tree3787939973598fae90579b7a6b69721cc31cebca /app-misc
parentsys-kernel/gentoo-sources: Linux patch 3.10.89 (diff)
downloadgentoo-751d0f79973aa5c2918b386e814aa3eda17df27b.tar.gz
gentoo-751d0f79973aa5c2918b386e814aa3eda17df27b.tar.bz2
gentoo-751d0f79973aa5c2918b386e814aa3eda17df27b.zip
app-misc/ca-certificates: rework py3 patch a bit more #561586
Rework some of the codec logic to make sure we can read files when in a non-UTF8 locale (like LANG=C), and it works w/py2.7 and py3.4.
Diffstat (limited to 'app-misc')
-rw-r--r--app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch21
1 files changed, 18 insertions, 3 deletions
diff --git a/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch b/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch
index 300ce479b227..d639aefb4c09 100644
--- a/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch
+++ b/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch
@@ -3,6 +3,19 @@ https://bugs.gentoo.org/548374
--- a/ca-certificates/mozilla/certdata2pem.py
+++ b/ca-certificates/mozilla/certdata2pem.py
+@@ -31,7 +31,11 @@ objects = []
+ # Dirty file parser.
+ in_data, in_multiline, in_obj = False, False, False
+ field, type, value, obj = None, None, None, dict()
+-for line in open('certdata.txt', 'r'):
++try:
++ f = open('certdata.txt', 'r', encoding='utf-8')
++except TypeError:
++ f = open('certdata.txt', 'r')
++for line in f:
+ # Ignore the file header.
+ if not in_data:
+ if line.startswith('BEGINDATA'):
@@ -53,7 +53,7 @@ for line in open('certdata.txt', 'r'):
if type == 'MULTILINE_OCTAL':
line = line.strip()
@@ -62,17 +75,19 @@ https://bugs.gentoo.org/548374
.replace(')', '=')\
.replace(',', '_')
- bname = bname.decode('string_escape')
+- fname = bname + '.crt'
+
+ # this is the only way to decode the way NSS stores multi-byte UTF-8
+ if bytes != str:
+ bname = bname.encode('utf-8')
+ bname = bname.decode('unicode_escape').encode('latin-1').decode('utf-8')
- fname = bname + '.crt'
++ fname = (bname + '.crt').encode('utf-8')
+
if os.path.exists(fname):
- print "Found duplicate certificate name %s, renaming." % bname
-+ print("Found duplicate certificate name %s, renaming." % bname)
- fname = bname + '_2.crt'
+- fname = bname + '_2.crt'
++ print("Found duplicate certificate name %s, renaming." % fname)
++ fname = (bname + '_2.crt').encode('utf-8')
f = open(fname, 'w')
f.write("-----BEGIN CERTIFICATE-----\n")
- f.write("\n".join(textwrap.wrap(base64.b64encode(obj['CKA_VALUE']), 64)))