X-Git-Url: https://git.mdrn.pl/django-ssify.git/blobdiff_plain/64c5163e7aead7eb60951e040998ade343c079c5..refs/heads/master:/ssify/middleware_debug.py diff --git a/ssify/middleware_debug.py b/ssify/middleware_debug.py index 863d8fe..f463d53 100644 --- a/ssify/middleware_debug.py +++ b/ssify/middleware_debug.py @@ -12,10 +12,18 @@ support as a proxy (i.e. Nginx with ssi=on). """ from __future__ import unicode_literals import re + try: from urllib.parse import urlparse except ImportError: from urlparse import urlparse + +try: + from django.urls import NoReverseMatch, reverse, resolve +except ImportError: + # Django < 2 + from django.core.urlresolvers import NoReverseMatch, reverse, resolve + from django.core.urlresolvers import resolve from .cache import get_caches @@ -29,8 +37,9 @@ SSI_INCLUDE = re.compile(r"") SSI_IF = re.compile(r"(?P
)" r"(?P.*?)(?:(?P.*?))?" r"", re.S) - # TODO: escaped? -SSI_VAR = re.compile(r"\$\{(?P.+)\}") # TODO: escaped? +SSI_VAR = re.compile(r"\$\{(?P.+)\}") + +UNESCAPE = re.compile(r'\\(.)') class SsiRenderMiddleware(object): @@ -85,9 +94,11 @@ class SsiRenderMiddleware(object): def ssi_set(match): """Interprets SSI set statement.""" - variables[match.group('var')] = match.group('value') + content = match.group('value') + content = re.sub(UNESCAPE, r'\1', content) + variables[match.group('var')] = content if conf.RENDER_VERBOSE: - return match.group(0) + return content else: return ""