From: Bernie Innocenti Date: Thu, 19 Nov 2009 19:53:55 +0000 (-0500) Subject: Anchor all file extension regexes to end of string X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=ad79f3880dad5a6fcc8529d682c263f74c959847;p=geekigeeki.git Anchor all file extension regexes to end of string --- diff --git a/geekigeeki.py b/geekigeeki.py index b6e802c..e7d7f7d 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -22,11 +22,11 @@ import cgi, sys, os, re, errno, stat, glob image_ext = 'png|gif|jpg|jpeg|bmp|ico' video_ext = "ogg|ogv|oga" # Not supported by Firefox 3.5: mkv|mpg|mpeg|mp4|avi|asf|flv|wmv|qt -image_re = re.compile(r".*\.(" + image_ext + "|" + video_ext + ")", re.IGNORECASE) -video_re = re.compile(r".*\.(" + video_ext + ")", re.IGNORECASE) +image_re = re.compile(r".*\.(" + image_ext + "|" + video_ext + ")$", re.IGNORECASE) +video_re = re.compile(r".*\.(" + video_ext + ")$", re.IGNORECASE) # FIXME: we accept stuff like foo/../bar and we shouldn't -file_re = re.compile(r"([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)") -url_re = re.compile(r"[a-z]{3,8}://[^\s'\"]+\S") +file_re = re.compile(r"([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)$") +url_re = re.compile(r"[a-z]{3,8}://[^\s'\"]+\S$") ext_re = re.compile(r"\.([^\./]+)$") # CGI stuff ---------------------------------------------------------