Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
a8eb7e57
Commit
a8eb7e57
authored
Jun 27, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restrict the set of characters allowed in locations further
parent
5b05ea88
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
common/lib/keystore/__init__.py
+12
-2
No files found.
common/lib/keystore/__init__.py
View file @
a8eb7e57
...
...
@@ -15,6 +15,8 @@ URL_RE = re.compile("""
(/(?P<revision>[^/]+))?
"""
,
re
.
VERBOSE
)
INVALID_CHARS
=
re
.
compile
(
r"[^\w-]"
)
class
Location
(
object
):
'''
...
...
@@ -26,6 +28,14 @@ class Location(object):
However, they can also be represented a dictionaries (specifying each component),
tuples or list (specified in order), or as strings of the url
'''
@classmethod
def
clean
(
cls
,
value
):
"""
Return value, made into a form legal for locations
"""
return
re
.
sub
(
'_+'
,
'_'
,
INVALID_CHARS
.
sub
(
'_'
,
value
))
def
__init__
(
self
,
location
):
"""
Create a new location that is a clone of the specifed one.
...
...
@@ -45,7 +55,7 @@ class Location(object):
In both the dict and list forms, the revision is optional, and can be ommitted.
None of the components of a location may contain the '/' character
Components must be composed of alphanumeric characters, or the characters _, and -
Components may be set to None, which may be interpreted by some contexts to mean
wildcard selection
...
...
@@ -88,7 +98,7 @@ class Location(object):
raise
InvalidLocationError
(
location
)
for
val
in
self
.
list
():
if
val
is
not
None
and
'/'
in
val
:
if
val
is
not
None
and
INVALID_CHARS
.
search
(
val
)
is
not
None
:
raise
InvalidLocationError
(
location
)
def
__str__
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment