﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
22294	length filter changes type of output to string if passed safe string	steve.pike@…	nobody	"if you do:

{{{
{% if some_string|length > 123 %}
Hurrah!
{% endif %}
}}}

what happens is what you expect to happen - the length of the string is determined and compared to the integer given in the condition.

However if you do this:

{{{
{% if some_safe_string|length > 123 %}
Booo!
{% endif %}
}}}

Then the result is non obvious, since passing a safe_string to length results in the output also being marked safe and thus changed into a safe *string*... on which you cannot do simple comparisons to integers in this way... (see: https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping and https://github.com/django/django/blob/master/django/template/defaultfilters.py#L581 )

This seems like a bug rather than a feature, but since the type of the result of the length filter is not stated in the docs ( https://docs.djangoproject.com/en/1.5/ref/templates/builtins/#length ) this is really misleading."	Cleanup/optimization	closed	Template system	dev	Normal	fixed	filter safe		Accepted	0	0	0	0	1	0
