django-bootstrap-form icon indicating copy to clipboard operation
django-bootstrap-form copied to clipboard

Removing |safe filter from help_text.

Open adamalton opened this issue 11 years ago • 5 comments

I've removed the |safe filter from the help_text as I can't see a reason to assume that it's safe (no more than the label, error messages or anything else). As always we should default to assuming that it's not. It can always be mark_safe()'d if necessary.

adamalton avatar Feb 15 '14 22:02 adamalton

The help_text is coded by developer, why should not assume that it's safe?

tzangms avatar Feb 17 '14 05:02 tzangms

Well, for a couple of reasons... The help_text could have been translated with ugettext and so isn't necessarily directly controlled by the developer. And also because even if it is coded by the developer, the developer will be expecting it to be escaped by django (like everything else is). It doesn't seem to make sense to special case the help_text.

Django's philosophy is to escape everything at the template stage, unless it's an instance of django.utils.safestring.SafeString (i.e. mark_safe() has been called on it). The help_text should be no exception to this, otherwise we wouldn't be escaping the labels or error messages or widget attributes or anything else under the control of the developer either.

People can call mark_safe() on their help_text if they want to use HTML in it. But we should default to escaping the same as everything else.

Adam

On Monday, 17 February 2014, tzangms [email protected] wrote:

The help_text is coded by developer, why should not assume that it's safe?

Reply to this email directly or view it on GitHubhttps://github.com/tzangms/django-bootstrap-form/pull/49#issuecomment-35229218 .

Sent from Gmail Mobile

adamalton avatar Feb 17 '14 08:02 adamalton

+1

ghost avatar Jul 25 '14 09:07 ghost

Hi, any chance we could get this merged in?

Thanks Adam

adamalton avatar Sep 14 '14 20:09 adamalton

For what it's worth, Django itself doesn't escape help_text in automatically generated forms.

timgraham avatar Jul 02 '15 16:07 timgraham