This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escape several fields in our template macros.
Django won't auto-escape these values, so we'll need to handle it ourselves.
- Loading branch information
CM Lubinski
committed
Aug 24, 2017
1 parent
3a21b40
commit fc59e01
Showing
2 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
"""Macros used to make a few common tasks in templates easier""" | ||
from django import template | ||
from django.utils.html import escape | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.inclusion_tag('regulations/macros/external_link.html') | ||
def external_link(url, text, classes="", title=""): | ||
return {"url": url, "text": text, "classes": classes, "title": title} | ||
return {"url": escape(url), "text": escape(text), | ||
"classes": escape(classes), "title": escape(title)} | ||
|
||
|
||
@register.inclusion_tag('regulations/macros/search_for.html') | ||
def search_for(terms, reg, version, text=None): | ||
if text is None: | ||
text = terms | ||
return {"terms": terms, "reg": reg, "version": version, "text": text} | ||
return {"terms": terms, "reg": reg, "version": version, | ||
"text": escape(text)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters