Ticket #6283: forms.patch
File forms.patch, 2.8 KB (added by , 17 years ago) |
---|
-
fields.py
18 18 19 19 from django.utils.translation import ugettext_lazy as _ 20 20 from django.utils.encoding import StrAndUnicode, smart_unicode, smart_str 21 from django.utils.safestring import mark_safe 21 22 22 23 from util import ErrorList, ValidationError 23 24 from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateTimeInput … … 66 67 # help_text -- An optional string to use as "help text" for this Field. 67 68 if label is not None: 68 69 label = smart_unicode(label) 69 self.required, self.label, self.initial = required, label, initial70 self.required, self.label, self.initial = required, mark_safe(label), initial 70 71 self.help_text = smart_unicode(help_text or '') 71 72 widget = widget or self.widget 72 73 if isinstance(widget, type): -
forms.py
5 5 from copy import deepcopy 6 6 7 7 from django.utils.datastructures import SortedDict 8 from django.utils.html import escape8 from django.utils.html import conditional_escape 9 9 from django.utils.encoding import StrAndUnicode, smart_unicode, force_unicode 10 10 from django.utils.safestring import mark_safe 11 11 … … 109 109 output, hidden_fields = [], [] 110 110 for name, field in self.fields.items(): 111 111 bf = BoundField(self, field, name) 112 bf_errors = self.error_class([ escape(error) for error in bf.errors]) # Escape and cache in local variable.112 bf_errors = self.error_class([conditional_escape(error) for error in bf.errors]) # Escape and cache in local variable. 113 113 if bf.is_hidden: 114 114 if bf_errors: 115 115 top_errors.extend(['(Hidden field %s) %s' % (name, force_unicode(e)) for e in bf_errors]) … … 118 118 if errors_on_separate_row and bf_errors: 119 119 output.append(error_row % force_unicode(bf_errors)) 120 120 if bf.label: 121 label = escape(force_unicode(bf.label))121 label = conditional_escape(force_unicode(bf.label)) 122 122 # Only add the suffix if the label does not end in 123 123 # punctuation. 124 124 if self.label_suffix: … … 302 302 303 303 If attrs are given, they're used as HTML attributes on the <label> tag. 304 304 """ 305 contents = contents or escape(self.label)305 contents = contents or conditional_escape(self.label) 306 306 widget = self.field.widget 307 307 id_ = widget.attrs.get('id') or self.auto_id 308 308 if id_: