Merge lp:~dooferlad/linaro-license-protection/fix_double_slash_in_links into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by James Tunnicliffe
Status: Merged
Approved by: Stevan Radaković
Approved revision: 110
Merged at revision: 113
Proposed branch: lp:~dooferlad/linaro-license-protection/fix_double_slash_in_links
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 41 lines (+13/-0)
2 files modified
license_protected_downloads/tests/test_views.py (+8/-0)
license_protected_downloads/views.py (+5/-0)
To merge this branch: bzr merge lp:~dooferlad/linaro-license-protection/fix_double_slash_in_links
Reviewer Review Type Date Requested Status
Stevan Radaković Approve
Review via email: mp+120838@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stevan Radaković (stevanr) wrote :

You have a copy-paste leftover comment in the test :)
Approving anyway, you can go on with merging when you update/remove the comment.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'license_protected_downloads/tests/test_views.py'
2--- license_protected_downloads/tests/test_views.py 2012-08-22 14:41:55 +0000
3+++ license_protected_downloads/tests/test_views.py 2012-08-22 17:38:31 +0000
4@@ -463,6 +463,14 @@
5 # If a build-info file has no information about this file
6 self.assertEqual(response.status_code, 403)
7
8+ def test_listings_do_not_contain_double_slash_in_link(self):
9+ target_file = 'images/'
10+ url = urlparse.urljoin("http://testserver/", target_file)
11+ response = self.client.get(url, follow=True)
12+
13+ # the directory open contains .hidden.txt - we shouldn't be able to
14+ # see it in the listing.
15+ self.assertNotContains(response, "//origen-blob.txt")
16
17 if __name__ == '__main__':
18 unittest.main()
19
20=== modified file 'license_protected_downloads/views.py'
21--- license_protected_downloads/views.py 2012-08-22 14:41:55 +0000
22+++ license_protected_downloads/views.py 2012-08-22 17:38:31 +0000
23@@ -67,6 +67,10 @@
24 if not re.search(r'^/', url) and url != '':
25 url = '/' + url
26
27+ # Since the code below assume no trailing slash, make sure that
28+ # there isn't one.
29+ url = re.sub(r'/$', '', url)
30+
31 pathname = os.path.join(path, name)
32 license_digest_list = is_protected(pathname)
33 license_list = License.objects.all_with_hashes(license_digest_list)
34@@ -267,6 +271,7 @@
35
36
37 def file_server(request, path):
38+ """Serve up a file / directory listing or license page as required"""
39 url = path
40 result = test_path(path)
41 if not result:

Subscribers

People subscribed via source and target branches