# HG changeset patch # User Todd Larsen # Date 1221801155 0 # Node ID a9b3d6c9d4f9b8c87c955bfff4d559d2d6c06a69 # Parent 87296bdfc9c619ac816b1e726acc8f5edbfb7bf1 Fix off-by-one corner case discovered during testing of /user/profile. diff -r 87296bdfc9c6 -r a9b3d6c9d4f9 app/soc/views/helpers/response_helpers.py --- a/app/soc/views/helpers/response_helpers.py Fri Sep 19 04:50:42 2008 +0000 +++ b/app/soc/views/helpers/response_helpers.py Fri Sep 19 05:12:35 2008 +0000 @@ -23,6 +23,7 @@ ] +import logging import urlparse from google.appengine.api import users @@ -202,7 +203,7 @@ """ http_from = request.META.get('HTTP_REFERER') - + if not http_from: # no HTTP referrer, so cannot possibly start with expected prefix return False @@ -215,7 +216,12 @@ if suffix: # remove suffix (such as a link name) before comparison - expected_prefix = expected_prefix[:-len(suffix)+1] + chars_to_remove = len(suffix) + + if not suffix.startswith('/'): + chars_to_remove = chars_to_remove + 1 + + expected_prefix = expected_prefix[:-chars_to_remove] if not from_path.startswith(expected_prefix): # expected prefix did not match first part of HTTP referrer path