Skip to content

Commit 9e954b2

Browse files
committed
docs: state that the variable block is read only in a bare block.super
1 parent 5a878be commit 9e954b2

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
- Django templates are also read as each page is put together (#273): a variable a
2424
child's `{% block %}` prints inside its parent's `<script>`, an `{% include %}` that ends
2525
the attribute value it stands in, or one of a name several files have outside HTML data,
26-
is reported as `xss` where it was not, as is `{{ block.super }}` printed through a
27-
filter or a tag. So is a template that includes Django's
26+
is reported as `xss` where it was not, as is the variable `block` named anywhere but in
27+
a bare `{{ block.super }}`. So is a template that includes Django's
2828
`django/forms/widgets/attrs.html` inside a tag, which prints attribute names, and a
2929
template including itself inside a tag or a script. A page beyond 8 MiB once put
3030
together, or a template with more than 64 pages, or 16 MiB in all, through names

‎docs/usage.md‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,18 +219,19 @@ Each page is also put together as Django renders it, and read once more (#273):
219219
templates it extends, each block taking the definition of the most derived one and `{{
220220
block.super }}` the next one up, and each template it includes in place. What a child's
221221
block prints inside its parent's `<script>`, or what an include puts inside an
222-
attribute, is read where it lands. `{{ block.super }}` is put in place only bare:
223-
through a filter or a tag, Django still prints the parent's markup, marked safe, and the
224-
template is not established. A name several files have, which Django resolves through
225-
loaders the analyzer does not read, counts as each of them: a page extending it must
226-
escape with each file, except those already in its chain, which Django leaves out, so
227-
that a template extending its own name extends another file of it; an include of it is
228-
accepted only in HTML data, never inside an attribute, a tag, a `<script>` or `<style>`
229-
block or a comment, and only when each file ends in HTML data, nothing of it left open.
230-
A template including itself is read the same way. A page beyond 8 MiB once put together,
231-
or a template with more than 64 pages, or 16 MiB in all, through the files the templates
232-
it extends may be, is not established, and is listed among the templates the analyzer
233-
could not read.
222+
attribute, is read where it lands. `{{ block.super }}` is put in place only bare: the
223+
variable `block` named anywhere else, through a filter, a tag or an alias (`{% with
224+
parent=block %}{{ parent.super }}`), may still print the parent's markup, marked safe,
225+
and the template is not established. A name several files have, which Django resolves
226+
through loaders the analyzer does not read, counts as each of them: a page extending it
227+
must escape with each file, except those already in its chain, which Django leaves out,
228+
so that a template extending its own name extends another file of it; an include of it
229+
is accepted only in HTML data, never inside an attribute, a tag, a `<script>` or
230+
`<style>` block or a comment, and only when each file ends in HTML data, nothing of it
231+
left open. A template including itself is read the same way. A page beyond 8 MiB once
232+
put together, or a template with more than 64 pages, or 16 MiB in all, through the files
233+
the templates it extends may be, is not established, and is listed among the templates
234+
the analyzer could not read.
234235

235236
The analyzer never assumes escaping where it cannot read the template. That covers a
236237
template file it cannot read, a template named by an expression, a template found

0 commit comments

Comments
 (0)