Prevent modification of auto generated files

This commit is contained in:
expo 2012-08-06 12:56:20 +02:00
parent 1ef274ec1d
commit a29fd964bd

View File

@ -107,6 +107,9 @@ 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()
autogeneratedmatch = re.search(r"\<\!--\s*(.*?(Do not edit|auto-generated).*?)\s*--\>", html, re.DOTALL + re.IGNORECASE)
if autogeneratedmatch:
return HttpResponse(autogeneratedmatch.group(1))
m = re.search(r"(.*)<head([^>]*)>(.*)</head>(.*)<body([^>]*)>(.*)</body>(.*)", html, re.DOTALL + re.IGNORECASE) m = re.search(r"(.*)<head([^>]*)>(.*)</head>(.*)<body([^>]*)>(.*)</body>(.*)", html, re.DOTALL + re.IGNORECASE)
if m: if m:
filefound = True filefound = True