summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-08-17 09:34:50 -0400
committerTim Graham <timograham@gmail.com>2015-09-23 19:31:09 -0400
commit04ee4059d71dbc6aa029907e251360eaf00e11bb (patch)
treed675a92c2f0beec5e3904c7b02e415d91d8e5c10 /django
parent3af9b70028487be81c4f6ca65ca0d1f2be337e4f (diff)
Refs #24022 -- Removed the ssi tag per deprecation timeline.
Diffstat (limited to 'django')
-rw-r--r--django/conf/__init__.py1
-rw-r--r--django/conf/global_settings.py4
-rw-r--r--django/core/checks/compatibility/django_1_8_0.py1
-rw-r--r--django/template/defaulttags.py77
-rw-r--r--django/template/engine.py10
-rw-r--r--django/template/utils.py1
-rw-r--r--django/test/signals.py1
7 files changed, 2 insertions, 93 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index ee9a1ee1c5..c0e44e24b2 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -99,7 +99,6 @@ class Settings(BaseSettings):
mod = importlib.import_module(self.SETTINGS_MODULE)
tuple_settings = (
- "ALLOWED_INCLUDE_ROOTS",
"INSTALLED_APPS",
"TEMPLATE_DIRS",
"LOCALE_PATHS",
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 6b759d8454..a6e3acf341 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -260,10 +260,6 @@ DISALLOWED_USER_AGENTS = []
ABSOLUTE_URL_OVERRIDES = {}
-# List of strings representing allowed prefixes for the {% ssi %} tag.
-# Example: ['/home/html', '/var/www']
-ALLOWED_INCLUDE_ROOTS = []
-
# List of compiled regular expression objects representing URLs that need not
# be reported by BrokenLinkEmailsMiddleware. Here are a few examples:
# import re
diff --git a/django/core/checks/compatibility/django_1_8_0.py b/django/core/checks/compatibility/django_1_8_0.py
index c0d8d0a779..ea82bf7c11 100644
--- a/django/core/checks/compatibility/django_1_8_0.py
+++ b/django/core/checks/compatibility/django_1_8_0.py
@@ -10,7 +10,6 @@ def check_duplicate_template_settings(app_configs, **kwargs):
if settings.TEMPLATES:
values = [
'TEMPLATE_DIRS',
- 'ALLOWED_INCLUDE_ROOTS',
'TEMPLATE_CONTEXT_PROCESSORS',
'TEMPLATE_DEBUG',
'TEMPLATE_LOADERS',
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 9a86279d38..ec1b486b24 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -1,7 +1,6 @@
"""Default tags used by the template system, available to all templates."""
from __future__ import unicode_literals
-import os
import re
import sys
import warnings
@@ -19,7 +18,7 @@ from django.utils.safestring import mark_safe
from .base import (
BLOCK_TAG_END, BLOCK_TAG_START, COMMENT_TAG_END, COMMENT_TAG_START,
SINGLE_BRACE_END, SINGLE_BRACE_START, VARIABLE_ATTRIBUTE_SEPARATOR,
- VARIABLE_TAG_END, VARIABLE_TAG_START, Context, Node, NodeList, Template,
+ VARIABLE_TAG_END, VARIABLE_TAG_START, Context, Node, NodeList,
TemplateSyntaxError, VariableDoesNotExist, kwarg_re,
render_value_in_context, token_kwargs,
)
@@ -373,44 +372,6 @@ class RegroupNode(Node):
return ''
-def include_is_allowed(filepath, allowed_include_roots):
- filepath = os.path.abspath(filepath)
- for root in allowed_include_roots:
- if filepath.startswith(root):
- return True
- return False
-
-
-class SsiNode(Node):
- def __init__(self, filepath, parsed):
- self.filepath = filepath
- self.parsed = parsed
-
- def render(self, context):
- filepath = self.filepath.resolve(context)
-
- if not include_is_allowed(filepath, context.template.engine.allowed_include_roots):
- if settings.DEBUG:
- return "[Didn't have permission to include file]"
- else:
- return '' # Fail silently for invalid includes.
- try:
- with open(filepath, 'r') as fp:
- output = fp.read()
- except IOError:
- output = ''
- if self.parsed:
- try:
- t = Template(output, name=filepath, engine=context.template.engine)
- return t.render(context)
- except TemplateSyntaxError as e:
- if settings.DEBUG:
- return "[Included template had syntax error: %s]" % e
- else:
- return '' # Fail silently for invalid included templates.
- return output
-
-
class LoadNode(Node):
def render(self, context):
return ''
@@ -1091,42 +1052,6 @@ def ifchanged(parser, token):
return IfChangedNode(nodelist_true, nodelist_false, *values)
-@register.tag
-def ssi(parser, token):
- """
- Outputs the contents of a given file into the page.
-
- Like a simple "include" tag, the ``ssi`` tag includes the contents
- of another file -- which must be specified using an absolute path --
- in the current page::
-
- {% ssi "/home/html/ljworld.com/includes/right_generic.html" %}
-
- If the optional "parsed" parameter is given, the contents of the included
- file are evaluated as template code, with the current context::
-
- {% ssi "/home/html/ljworld.com/includes/right_generic.html" parsed %}
- """
- warnings.warn(
- "The {% ssi %} tag is deprecated. Use the {% include %} tag instead.",
- RemovedInDjango110Warning,
- )
-
- bits = token.split_contents()
- parsed = False
- if len(bits) not in (2, 3):
- raise TemplateSyntaxError("'ssi' tag takes one argument: the path to"
- " the file to be included")
- if len(bits) == 3:
- if bits[2] == 'parsed':
- parsed = True
- else:
- raise TemplateSyntaxError("Second (optional) argument to %s tag"
- " must be 'parsed'" % bits[0])
- filepath = parser.compile_filter(bits[1])
- return SsiNode(filepath, parsed)
-
-
def find_library(parser, name):
try:
return parser.libraries[name]
diff --git a/django/template/engine.py b/django/template/engine.py
index 2c9e2c2892..75d39c82a0 100644
--- a/django/template/engine.py
+++ b/django/template/engine.py
@@ -23,14 +23,11 @@ class Engine(object):
'django.template.loader_tags',
]
- def __init__(self, dirs=None, app_dirs=False,
- allowed_include_roots=None, context_processors=None,
+ def __init__(self, dirs=None, app_dirs=False, context_processors=None,
debug=False, loaders=None, string_if_invalid='',
file_charset='utf-8', libraries=None, builtins=None):
if dirs is None:
dirs = []
- if allowed_include_roots is None:
- allowed_include_roots = []
if context_processors is None:
context_processors = []
if loaders is None:
@@ -46,13 +43,8 @@ class Engine(object):
if builtins is None:
builtins = []
- if isinstance(allowed_include_roots, six.string_types):
- raise ImproperlyConfigured(
- "allowed_include_roots must be a tuple, not a string.")
-
self.dirs = dirs
self.app_dirs = app_dirs
- self.allowed_include_roots = allowed_include_roots
self.context_processors = context_processors
self.debug = debug
self.loaders = loaders
diff --git a/django/template/utils.py b/django/template/utils.py
index cbf0de148d..d809a47f58 100644
--- a/django/template/utils.py
+++ b/django/template/utils.py
@@ -40,7 +40,6 @@ class EngineHandler(object):
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': settings.TEMPLATE_DIRS,
'OPTIONS': {
- 'allowed_include_roots': settings.ALLOWED_INCLUDE_ROOTS,
'context_processors': settings.TEMPLATE_CONTEXT_PROCESSORS,
'debug': settings.TEMPLATE_DEBUG,
'loaders': settings.TEMPLATE_LOADERS,
diff --git a/django/test/signals.py b/django/test/signals.py
index f7836637e8..9f7958d83b 100644
--- a/django/test/signals.py
+++ b/django/test/signals.py
@@ -85,7 +85,6 @@ def reset_template_engines(**kwargs):
if kwargs['setting'] in {
'TEMPLATES',
'TEMPLATE_DIRS',
- 'ALLOWED_INCLUDE_ROOTS',
'TEMPLATE_CONTEXT_PROCESSORS',
'TEMPLATE_DEBUG',
'TEMPLATE_LOADERS',