Merge lp:~cjwatson/click-apparmor/unicode-manifest into lp:click-apparmor

Proposed by Colin Watson
Status: Merged
Merged at revision: 91
Proposed branch: lp:~cjwatson/click-apparmor/unicode-manifest
Merge into: lp:click-apparmor
Diff against target: 111 lines (+21/-12)
3 files modified
apparmor/click.py (+2/-2)
debian/changelog (+6/-0)
test-clicktool.py (+13/-10)
To merge this branch: bzr merge lp:~cjwatson/click-apparmor/unicode-manifest
Reviewer Review Type Date Requested Status
Ubuntu Security Team Pending
Review via email: mp+192951@code.launchpad.net

Description of the change

Treat manifests as UTF-8, even in non-UTF-8 locales such as those in use when running under PackageKit.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apparmor/click.py'
2--- apparmor/click.py 2013-09-23 23:17:28 +0000
3+++ apparmor/click.py 2013-10-28 21:18:44 +0000
4@@ -263,7 +263,7 @@
5
6 def read_click_manifest(manifest):
7 '''Read click manifest'''
8- f = open(manifest, "r")
9+ f = open(manifest, "r", encoding="UTF-8")
10 j = json.load(f)
11 for field in required_click_fields:
12 if not field in j:
13@@ -274,7 +274,7 @@
14
15 def read_apparmor_manifest(manifest, app):
16 '''Read AppArmor manifest from click package'''
17- f = open(manifest, "r")
18+ f = open(manifest, "r", encoding="UTF-8")
19 j = json.load(f)
20 if (len(j.keys()) == 1) and app in j:
21 j = j[app]
22
23=== modified file 'debian/changelog'
24--- debian/changelog 2013-10-28 21:12:25 +0000
25+++ debian/changelog 2013-10-28 21:18:44 +0000
26@@ -1,3 +1,9 @@
27+click-apparmor (0.1.12) UNRELEASED; urgency=low
28+
29+ * Treat manifests as UTF-8, even in non-UTF-8 locales (LP: #1245677).
30+
31+ -- Colin Watson <cjwatson@ubuntu.com> Mon, 28 Oct 2013 14:14:23 -0700
32+
33 click-apparmor (0.1.11) saucy; urgency=low
34
35 * don't traceback on os.remove (LP: #1234908)
36
37=== modified file 'test-clicktool.py'
38--- test-clicktool.py 2013-09-04 22:48:25 +0000
39+++ test-clicktool.py 2013-10-28 21:18:44 +0000
40@@ -1,4 +1,5 @@
41 #!/usr/bin/python3
42+# -*- coding: UTF-8 -*-
43
44 # ------------------------------------------------------------------
45 #
46@@ -11,7 +12,7 @@
47 # ------------------------------------------------------------------
48
49 # not needed for python3, but pyflakes is grumpy without it
50-from __future__ import print_function
51+from __future__ import print_function, unicode_literals
52
53 from apparmor import click
54 from apparmor.click import AppName
55@@ -43,15 +44,16 @@
56 j['version'] = version
57 j['hooks'] = dict()
58 j['title'] = "Some silly demo app called %s" % (name)
59- j['maintainer'] = 'Buggy McJerkerson <buggy@bad.soft.warez>'
60+ j['maintainer'] = 'Büggy McJerkerson <buggy@bad.soft.warez>'
61 return j
62
63 def _add_app_to_json(self, app):
64 j = self.manifest_json
65 j['hooks'][app] = dict()
66 j['hooks'][app]['apparmor'] = "apparmor/%s.json" % (app)
67- with open(self.click_manifest, "w") as f:
68- json.dump(j, f, indent=2, separators=(',', ': '), sort_keys=True)
69+ with open(self.click_manifest, "w", encoding="UTF-8") as f:
70+ json.dump(j, f, indent=2, separators=(',', ': '), sort_keys=True,
71+ ensure_ascii=False)
72
73 def add_package(self, name, version, framework=None):
74 self.package = name
75@@ -65,9 +67,9 @@
76 self.manifest_json['framework'] = framework
77 self.click_manifest = os.path.join(self.click_pkgdir, "%s.manifest" %
78 (name))
79- with open(self.click_manifest, "w+") as f:
80+ with open(self.click_manifest, "w+", encoding="UTF-8") as f:
81 json.dump(self.manifest_json, f, indent=2, separators=(',', ': '),
82- sort_keys=True)
83+ sort_keys=True, ensure_ascii=False)
84
85 def add_app(self, appname, manifest=None):
86 os.mkdir(os.path.join(self.click_pkgdir, "apparmor"))
87@@ -75,7 +77,7 @@
88 (appname))
89 self._add_app_to_json(appname)
90
91- with open(aa_json, "w+") as f:
92+ with open(aa_json, "w+", encoding="UTF-8") as f:
93 if manifest:
94 f.write(manifest)
95 os.symlink(aa_json, os.path.join(self.click_dir,
96@@ -260,11 +262,12 @@
97 j['version'] = "0.1"
98 j['hooks'] = dict()
99 j['title'] = "Some silly demo app"
100- j['maintainer'] = 'Buggy McJerkerson <buggy@bad.soft.warez>'
101+ j['maintainer'] = 'Büggy McJerkerson <buggy@bad.soft.warez>'
102
103 self.click_manifest = os.path.join(self.tmpdir, "test-app.manifest")
104- with open(self.click_manifest, "w+") as f:
105- json.dump(j, f, indent=2, separators=(',', ': '), sort_keys=True)
106+ with open(self.click_manifest, "w+", encoding="UTF-8") as f:
107+ json.dump(j, f, indent=2, separators=(',', ': '), sort_keys=True,
108+ ensure_ascii=False)
109 try:
110 apparmor.click.read_click_manifest(self.click_manifest)
111 except click.AppArmorException:

Subscribers

People subscribed via source and target branches

to all changes: