Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2006-05-07 12:31:19 +0200
committerArthur de Jong <arthur@arthurdejong.org>2006-05-07 12:31:19 +0200
commitc411aafcb1be55376d9228183d518e977741cf02 (patch)
tree60ba3ad7c621830c491668e1224863eea5367421
parent5bd6ce9be9978a91a7a74f653db8daf3d9bbdf79 (diff)
ensure that we are not importing anything weird by using invalid scheme names
git-svn-id: http://arthurdejong.org/svn/webcheck/webcheck@260 86f53f14-5ff3-0310-afe5-9b438ce3f40c
-rw-r--r--schemes/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/schemes/__init__.py b/schemes/__init__.py
index cc466a5..b9a9eeb 100644
--- a/schemes/__init__.py
+++ b/schemes/__init__.py
@@ -32,11 +32,20 @@ Each module should export the following function:
returned if the content type is mentioned in the acceptedtypes
list."""
+import re
+
+# pattern to match valid scheme names
+_schemepattern = re.compile('^[A-Za-z][A-Za-z0-9]*$')
+
# a map of schemes to modules
_schememodules = {}
def get_schememodule(scheme):
"""Look up the correct module for the specified scheme."""
+ # check validity of scheme name
+ if not _schemepattern.search(scheme):
+ return None
+ # find module for scheme name
if not _schememodules.has_key(scheme):
try:
_schememodules[scheme] = \