Merge lp:~allenap/launchpad/ec2-test-remote-non-ascii-issue-bug-447247 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~allenap/launchpad/ec2-test-remote-non-ascii-issue-bug-447247
Merge into: lp:launchpad
Diff against target: 69 lines
1 file modified
lib/devscripts/ec2test/ec2test-remote.py (+15/-8)
To merge this branch: bzr merge lp:~allenap/launchpad/ec2-test-remote-non-ascii-issue-bug-447247
Reviewer Review Type Date Requested Status
Abel Deuring (community) Approve
Review via email: mp+13126@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Encode the summary before appending it to the log files. I also fixed some lint.

Revision history for this message
Gavin Panella (allenap) wrote :

The following diff was also needed because branch.revno() is an int, and can't be escaped directly, nor does it need to be.

=== modified file 'lib/devscripts/ec2test/ec2test-remote.py'
--- lib/devscripts/ec2test/ec2test-remote.py 2009-10-09 14:50:33 +0000
+++ lib/devscripts/ec2test/ec2test-remote.py 2009-10-09 15:04:24 +0000
@@ -339,8 +339,9 @@
                         'revno': branch.revno()}
                 write(
                     '- %(name)s\n %(branch)s\n %(revno)d\n' % data)
- escaped_data = dict(
- (key, escape(value)) for (key, value) in data.iteritems())
+ escaped_data = {'name': escape(name),
+ 'branch': escape(branch.get_parent()),
+ 'revno': branch.revno()}
                 index_file.write(textwrap.dedent('''\
                     <dt>%(name)s</dt>
                       <dd>%(branch)s</dd>

Revision history for this message
Abel Deuring (adeuring) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/devscripts/ec2test/ec2test-remote.py'
2--- lib/devscripts/ec2test/ec2test-remote.py 2009-09-14 22:59:32 +0000
3+++ lib/devscripts/ec2test/ec2test-remote.py 2009-10-09 15:06:12 +0000
4@@ -17,6 +17,8 @@
5 import time
6 import traceback
7
8+from xml.sax.saxutils import escape
9+
10 import bzrlib.branch
11 import bzrlib.config
12 import bzrlib.email_message
13@@ -140,7 +142,8 @@
14 # since someone else might try to write to them later.
15 summary_file.close()
16 if self.email is not None:
17- subject = 'Test results: %s' % (result and 'FAILURE' or 'SUCCESS')
18+ subject = 'Test results: %s' % (
19+ result and 'FAILURE' or 'SUCCESS')
20 summary_file = open(self.logger.summary_filename, 'r')
21 bzrlib.email_message.EmailMessage.send(
22 config, self.email[0], self.email,
23@@ -299,7 +302,7 @@
24 'trunk_revno': branch.revno()}
25 index_file.write(textwrap.dedent('''\
26 <p><strong>%s</strong></p>
27- ''' % (msg,)))
28+ ''' % (escape(msg),)))
29 write(msg)
30 tree = bzrlib.workingtree.WorkingTree.open(self.test_dir)
31 parent_ids = tree.get_parent_ids()
32@@ -309,15 +312,16 @@
33 index_file.write('<p>(no merged branch)</p>\n')
34 write('(no merged branch)')
35 else:
36- summary = branch.repository.get_revision(parent_ids[1]).get_summary()
37+ summary = (
38+ branch.repository.get_revision(parent_ids[1]).get_summary())
39 data = {'name': self.public_branch.encode('utf-8'),
40 'revno': self.public_branch_revno,
41- 'commit': summary}
42-
43- msg = '%(name)s, revision %(revno)d (commit message: %(commit)s)\n' % data
44+ 'commit': summary.encode('utf-8')}
45+ msg = ('%(name)s, revision %(revno)d '
46+ '(commit message: %(commit)s)\n' % data)
47 index_file.write(textwrap.dedent('''\
48 <p>Merged with<br />%(msg)s</p>
49- ''' % {'msg': msg}))
50+ ''' % {'msg': escape(msg)}))
51 write("Merged with")
52 write(msg)
53
54@@ -335,11 +339,14 @@
55 'revno': branch.revno()}
56 write(
57 '- %(name)s\n %(branch)s\n %(revno)d\n' % data)
58+ escaped_data = {'name': escape(name),
59+ 'branch': escape(branch.get_parent()),
60+ 'revno': branch.revno()}
61 index_file.write(textwrap.dedent('''\
62 <dt>%(name)s</dt>
63 <dd>%(branch)s</dd>
64 <dd>%(revno)s</dd>
65- ''' % data))
66+ ''' % escaped_data))
67 index_file.write(textwrap.dedent('''\
68 </dl>
69 </body>