Fix off-by-one corner case discovered during testing of /user/profile.
--- 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