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
=== modified file 'license_protected_downloads/tests/test_views.py'
--- license_protected_downloads/tests/test_views.py 2012-08-22 14:41:55 +0000
+++ license_protected_downloads/tests/test_views.py 2012-08-22 17:38:31 +0000
@@ -463,6 +463,14 @@
463 # If a build-info file has no information about this file463 # If a build-info file has no information about this file
464 self.assertEqual(response.status_code, 403)464 self.assertEqual(response.status_code, 403)
465465
466 def test_listings_do_not_contain_double_slash_in_link(self):
467 target_file = 'images/'
468 url = urlparse.urljoin("http://testserver/", target_file)
469 response = self.client.get(url, follow=True)
470
471 # the directory open contains .hidden.txt - we shouldn't be able to
472 # see it in the listing.
473 self.assertNotContains(response, "//origen-blob.txt")
466474
467if __name__ == '__main__':475if __name__ == '__main__':
468 unittest.main()476 unittest.main()
469477
=== modified file 'license_protected_downloads/views.py'
--- license_protected_downloads/views.py 2012-08-22 14:41:55 +0000
+++ license_protected_downloads/views.py 2012-08-22 17:38:31 +0000
@@ -67,6 +67,10 @@
67 if not re.search(r'^/', url) and url != '':67 if not re.search(r'^/', url) and url != '':
68 url = '/' + url68 url = '/' + url
6969
70 # Since the code below assume no trailing slash, make sure that
71 # there isn't one.
72 url = re.sub(r'/$', '', url)
73
70 pathname = os.path.join(path, name)74 pathname = os.path.join(path, name)
71 license_digest_list = is_protected(pathname)75 license_digest_list = is_protected(pathname)
72 license_list = License.objects.all_with_hashes(license_digest_list)76 license_list = License.objects.all_with_hashes(license_digest_list)
@@ -267,6 +271,7 @@
267271
268272
269def file_server(request, path):273def file_server(request, path):
274 """Serve up a file / directory listing or license page as required"""
270 url = path275 url = path
271 result = test_path(path)276 result = test_path(path)
272 if not result:277 if not result:

Subscribers

People subscribed via source and target branches