diff options
author | Tim Graham <timograham@gmail.com> | 2016-01-22 19:01:54 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-03-05 11:00:12 -0500 |
commit | c3e22ba78d1f6a780d1181cb16e3240136f2ae59 (patch) | |
tree | 9b8cb65ffc2a7a8797a294093240befd449c9aa2 /django/utils/safestring.py | |
parent | 9ed4a788aa8d6ba6a57a2daa15253c3047048dfb (diff) | |
download | django-24046.tar.gz |
Refs #24046 -- POC for mark_for_escaping() removal.24046
Diffstat (limited to 'django/utils/safestring.py')
-rw-r--r-- | django/utils/safestring.py | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/django/utils/safestring.py b/django/utils/safestring.py index 3d3bf1b62a..40be743c04 100644 --- a/django/utils/safestring.py +++ b/django/utils/safestring.py @@ -8,31 +8,6 @@ from django.utils import six from django.utils.functional import Promise, curry -class EscapeData(object): - pass - - -class EscapeBytes(bytes, EscapeData): - """ - A byte string that should be HTML-escaped when output. - """ - pass - - -class EscapeText(six.text_type, EscapeData): - """ - A unicode string object that should be HTML-escaped when output. - """ - pass - -if six.PY3: - EscapeString = EscapeText -else: - EscapeString = EscapeBytes - # backwards compatibility for Python 2 - EscapeUnicode = EscapeText - - class SafeData(object): def __html__(self): """ @@ -128,20 +103,3 @@ def mark_safe(s): if isinstance(s, (six.text_type, Promise)): return SafeText(s) return SafeString(str(s)) - - -def mark_for_escaping(s): - """ - Explicitly mark a string as requiring HTML escaping upon output. Has no - effect on SafeData subclasses. - - Can be called multiple times on a single string (the resulting escaping is - only applied once). - """ - if hasattr(s, '__html__') or isinstance(s, EscapeData): - return s - if isinstance(s, bytes) or (isinstance(s, Promise) and s._delegate_bytes): - return EscapeBytes(s) - if isinstance(s, (six.text_type, Promise)): - return EscapeText(s) - return EscapeString(str(s)) |