diff --git a/lms/envs/common.py b/lms/envs/common.py index dbca00c5841fce44268225fd96a4ecc7ad845bdc..7d3611e66559ca7ee7a4b0f861d1d9e68d617730 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -410,8 +410,12 @@ LMS_MIGRATION_ALLOWED_IPS = [] # These are standard regexes for pulling out info like course_ids, usage_ids, etc. # They are used so that URLs with deprecated-format strings still work. -COURSE_ID_PATTERN = r'(?P<course_id>(?:[^/]+/[^/]+/[^/]+)|(?:[^/]+))' -COURSE_KEY_PATTERN = r'(?P<course_key_string>(?:[^/]+/[^/]+/[^/]+)|(?:[^/]+))' +# Note: these intentionally greedily grab all chars up to the next slash including any pluses +# DHM: I really wanted to ensure the separators were the same (+ or /) but all patts I tried had +# too many inadvertent side effects :-( +COURSE_KEY_PATTERN = r'(?P<course_key_string>[^/+]+(/|\+)[^/+]+(/|\+)[^/]+)' +COURSE_ID_PATTERN = COURSE_KEY_PATTERN.replace('course_key_string', 'course_id') + USAGE_KEY_PATTERN = r'(?P<usage_key_string>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' ASSET_KEY_PATTERN = r'(?P<asset_key_string>(?:/?c4x(:/)?/[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))' USAGE_ID_PATTERN = r'(?P<usage_id>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))'