From e8beb4d19b18bc7c765e9e355bd5759f52c6f3b1 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Thu, 21 Nov 2013 08:41:26 -0500 Subject: [PATCH] Allow colons in Locator fields. --- common/lib/xmodule/xmodule/modulestore/parsers.py | 2 +- .../xmodule/xmodule/modulestore/tests/test_locators.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/modulestore/parsers.py b/common/lib/xmodule/xmodule/modulestore/parsers.py index 64d3c25a51..dbef47d610 100644 --- a/common/lib/xmodule/xmodule/modulestore/parsers.py +++ b/common/lib/xmodule/xmodule/modulestore/parsers.py @@ -7,7 +7,7 @@ BLOCK_PREFIX = r"block/" # Prefix for the version portion of a locator URL, when it is preceded by a course ID VERSION_PREFIX = r"version/" -ALLOWED_ID_CHARS = r'[a-zA-Z0-9_\-~.]' +ALLOWED_ID_CHARS = r'[a-zA-Z0-9_\-~.:]' URL_RE_SOURCE = r""" (?Pedx://)? diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py b/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py index c6c21c1540..e9fc4ecf73 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_locators.py @@ -249,6 +249,16 @@ class LocatorTest(TestCase): version_guid=ObjectId(test_id_loc) ) + def test_colon_name(self): + """ + It seems we used to use colons in names; so, ensure they're acceptable. + """ + course_id = 'mit.eecs-1' + branch = 'foo' + usage_id = 'problem:with-colon~2' + testobj = BlockUsageLocator(course_id=course_id, branch=branch, usage_id=usage_id) + self.check_block_locn_fields(testobj, 'Cannot handle colon', course_id=course_id, branch=branch, block=usage_id) + def test_repr(self): testurn = 'mit.eecs.6002x/' + BRANCH_PREFIX + 'published/' + BLOCK_PREFIX + 'HW3' testobj = BlockUsageLocator(course_id=testurn)