From ad79f3880dad5a6fcc8529d682c263f74c959847 Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Thu, 19 Nov 2009 14:53:55 -0500 Subject: [PATCH] Anchor all file extension regexes to end of string --- geekigeeki.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 --------------------------------------------------------- -- 2.25.1