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