ignorecase when finding html tags

This commit is contained in:
Martin Green 2011-08-08 12:58:02 +01:00
parent fe1989001c
commit 9878cf890d

View File

@ -56,17 +56,17 @@ def flatpage(request, path):
if path.endswith(".htm") or path.endswith(".html"):
html = o.read()
m = re.search(r"<head>(.*)</head>.*<body[^>]*>(.*)</body>", html, re.DOTALL)
m = re.search(r"<head>(.*)</head>.*<body[^>]*>(.*)</body>", html, re.DOTALL + re.IGNORECASE)
if m:
head, body = m.groups()
else:
return HttpResponse(html + "Page could not be split into header and body")
m = re.search(r"<title>(.*)</title>", head, re.DOTALL)
m = re.search(r"<title>(.*)</title>", head, re.DOTALL + re.IGNORECASE)
if m:
title, = m.groups()
else:
title = ""
linksmatch = re.match('(.*)<ul id="links">', body, re.DOTALL)
linksmatch = re.match('(.*)<ul id="links">', body, re.DOTALL + re.IGNORECASE)
if linksmatch:
body, = linksmatch.groups()
if re.search(r"iso-8859-1", html):
@ -106,12 +106,12 @@ def editflatpage(request, path):
filepath = os.path.normpath(settings.EXPOWEB + path)
o = open(filepath, "r")
html = o.read()
m = re.search(r"<head>(.*)</head>.*<body[^>]*>(.*)</body>", html, re.DOTALL)
m = re.search(r"<head>(.*)</head>.*<body[^>]*>(.*)</body>", html, re.DOTALL + re.IGNORECASE)
if m:
filefound = True
head, body = m.groups()
if re.search(r"iso-8859-1", html):
linksmatch = re.match('(.*)<ul id="links">', body, re.DOTALL)
linksmatch = re.match('(.*)<ul id="links">', body, re.DOTALL + re.IGNORECASE)
if linksmatch:
body, = linksmatch.groups()
body = unicode(body, "iso-8859-1")
@ -132,7 +132,7 @@ def editflatpage(request, path):
return HttpResponseRedirect(reverse('flatpage', args=[path])) # Redirect after POST
else:
if filefound:
m = re.search(r"<title>(.*)</title>", head, re.DOTALL)
m = re.search(r"<title>(.*)</title>", head, re.DOTALL + re.IGNORECASE)
if m:
title, = m.groups()
else: