From e8e48e36abeab2e05f2e6cde0a8072ef76f20ba5 Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Sat, 2 May 2009 11:21:24 +0200 Subject: [PATCH] Simplify filetype matching regexes --- geekigeeki.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/geekigeeki.py b/geekigeeki.py index 470752d..a36eced 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -27,10 +27,11 @@ title_done = False import cgi, sys, os, re, errno, stat # FIXME: we accept stuff like foo/../bar and we shouldn't -file_re = re.compile(r"^\b([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)\b$") -img_re = re.compile(r"^.*\.(png|gif|jpg|jpeg|bmp|ico|ogm|ogg|mkv|mpg|mpeg|mp4|avi|asf|flv|wmv|qt)$", re.IGNORECASE) -video_re = re.compile(r"^.*\.(ogm|ogg|mkv|mpg|mpeg|mp4|avi|asf|flv|wmv|qt)$", re.IGNORECASE) -url_re = re.compile(r"^[a-z]{3,8}://[^\s'\"]+\S$") +file_re = re.compile(r"([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)") +video_ext = "ogg|ogv|oga" # Not supported by Firefox 3.5: mkv|mpg|mpeg|mp4|avi|asf|flv|wmv|qt +img_re = re.compile(r".*\.(png|gif|jpg|jpeg|bmp|ico|" + video_ext + ")", re.IGNORECASE) +video_re = re.compile(r".*\.(" + video_ext + ")", re.IGNORECASE) +url_re = re.compile(r"[a-z]{3,8}://[^\s'\"]+\S") ext_re = re.compile(r"\.([^\./]+)$") # CGI stuff --------------------------------------------------------- -- 2.25.1