* [gentoo-commits] repo/gentoo:master commit in: app-misc/ca-certificates/files/
@ 2015-09-29 0:38 Mike Frysinger
0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2015-09-29 0:38 UTC (permalink / raw
To: gentoo-commits
commit: 751d0f79973aa5c2918b386e814aa3eda17df27b
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 29 00:37:37 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Sep 29 00:38:38 2015 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=751d0f79
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.
...certificates-20150426-nss-certdata2pem-py3.patch | 21 ++++++++++++++++++---
1 file 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 300ce47..d639aef 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)))
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-09-29 0:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-29 0:38 [gentoo-commits] repo/gentoo:master commit in: app-misc/ca-certificates/files/ Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox