From 97c2e9ec802f742c48874a1baf433fa3fbecd0ba Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Mon, 24 Jun 2013 16:39:49 -0400 Subject: [PATCH] Make url matching regex flexible to allow for browsers that munged :// into :/ --- .../xmodule/xmodule/modulestore/__init__.py | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index 87e5bc04c1..2fa12e2e90 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -16,16 +16,7 @@ log = logging.getLogger('mitx.' + 'modulestore') URL_RE = re.compile(""" - (?P[^:]+):// - (?P[^/]+)/ - (?P[^/]+)/ - (?P[^/]+)/ - (?P[^@]+) - (@(?P[^/]+))? - """, re.VERBOSE) - -MISSING_SLASH_URL_RE = re.compile(""" - (?P[^:]+):/ + (?P[^:]+)://? (?P[^/]+)/ (?P[^/]+)/ (?P[^/]+)/ @@ -180,13 +171,8 @@ class Location(_LocationBase): if isinstance(location, basestring): match = URL_RE.match(location) if match is None: - # cdodge: - # check for a dropped slash near the i4x:// element of the location string. This can happen with some - # redirects (e.g. edx.org -> www.edx.org which I think happens in Nginx) - match = MISSING_SLASH_URL_RE.match(location) - if match is None: - log.debug('location is instance of %s but no URL match' % basestring) - raise InvalidLocationError(location) + log.debug('location is instance of %s but no URL match' % basestring) + raise InvalidLocationError(location) groups = match.groupdict() check_dict(groups) return _LocationBase.__new__(_cls, **groups)