From 70a743f88bd1639bbf3b3fc38f8562f6f5b7133c Mon Sep 17 00:00:00 2001 From: expo Date: Mon, 6 Aug 2012 12:56:20 +0200 Subject: [PATCH] Prevent modification of auto generated files --- flatpages/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flatpages/views.py b/flatpages/views.py index 6fb68bb..3a1bc40 100644 --- a/flatpages/views.py +++ b/flatpages/views.py @@ -107,6 +107,9 @@ def editflatpage(request, path): filepath = os.path.normpath(settings.EXPOWEB + path) o = open(filepath, "r") 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"(.*)]*)>(.*)(.*)]*)>(.*)(.*)", html, re.DOTALL + re.IGNORECASE) if m: filefound = True