Merge lp:~wgrant/launchpad/bug-736633 into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 12614
Proposed branch: lp:~wgrant/launchpad/bug-736633
Merge into: lp:launchpad
Diff against target: 28 lines (+4/-2)
2 files modified
lib/canonical/librarian/ftests/test_web.py (+3/-1)
lib/canonical/librarian/web.py (+1/-1)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-736633
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+53746@code.launchpad.net

Commit message

[r=lifeless][bug=736633] 404 on invalid old librarian URLs instead of crashing.

Description of the change

The librarian's old URL handler (parsing paths of the form /content/alias/filename) breaks when handling a non-integral alias ID. Trivial fix.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/librarian/ftests/test_web.py'
2--- lib/canonical/librarian/ftests/test_web.py 2011-02-24 04:33:55 +0000
3+++ lib/canonical/librarian/ftests/test_web.py 2011-03-17 06:56:36 +0000
4@@ -159,9 +159,11 @@
5 old_url = uri_path_replace(url, str(aid), '42/%d' % aid)
6 self.assertEqual(urlopen(old_url).read(), 'sample')
7
8- # If the content id is not an integer, a 404 is raised
9+ # If the content and alias IDs are not integers, a 404 is raised
10 old_url = uri_path_replace(url, str(aid), 'foo/%d' % aid)
11 self.require404(old_url)
12+ old_url = uri_path_replace(url, str(aid), '%d/foo' % aid)
13+ self.require404(old_url)
14
15 def test_404(self):
16 client = LibrarianClient()
17
18=== modified file 'lib/canonical/librarian/web.py'
19--- lib/canonical/librarian/web.py 2010-10-25 20:42:59 +0000
20+++ lib/canonical/librarian/web.py 2011-03-17 06:56:36 +0000
21@@ -80,7 +80,7 @@
22 self.aliasID = int(filename)
23 except ValueError:
24 log.msg(
25- "404 (old URL): alias is not an int: %r" % (name,))
26+ "404 (old URL): alias is not an int: %r" % (filename,))
27 return fourOhFour
28 filename = request.postpath[0]
29