mirror of https://github.com/django/django.git
Fixed #11972: Corrected title filter handling of numbers followed by letters. Thanks schwank@gmail.com and Randy Barlow.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11822 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
2659429df4
commit
f761802b22
2
AUTHORS
2
AUTHORS
|
@ -55,6 +55,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
Niran Babalola <niran@niran.org>
|
Niran Babalola <niran@niran.org>
|
||||||
Morten Bagai <m@bagai.com>
|
Morten Bagai <m@bagai.com>
|
||||||
Mikaël Barbero <mikael.barbero nospam at nospam free.fr>
|
Mikaël Barbero <mikael.barbero nospam at nospam free.fr>
|
||||||
|
Randy Barlow <randy@electronsweatshop.com>
|
||||||
Scott Barr <scott@divisionbyzero.com.au>
|
Scott Barr <scott@divisionbyzero.com.au>
|
||||||
Jiri Barton
|
Jiri Barton
|
||||||
Ned Batchelder <http://www.nedbatchelder.com/>
|
Ned Batchelder <http://www.nedbatchelder.com/>
|
||||||
|
@ -382,6 +383,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
Massimo Scamarcia <massimo.scamarcia@gmail.com>
|
Massimo Scamarcia <massimo.scamarcia@gmail.com>
|
||||||
David Schein
|
David Schein
|
||||||
Bernd Schlapsi
|
Bernd Schlapsi
|
||||||
|
schwank@gmail.com
|
||||||
scott@staplefish.com
|
scott@staplefish.com
|
||||||
Ilya Semenov <semenov@inetss.com>
|
Ilya Semenov <semenov@inetss.com>
|
||||||
serbaut@gmail.com
|
serbaut@gmail.com
|
||||||
|
|
|
@ -249,7 +249,8 @@ stringformat.is_safe = True
|
||||||
|
|
||||||
def title(value):
|
def title(value):
|
||||||
"""Converts a string into titlecase."""
|
"""Converts a string into titlecase."""
|
||||||
return re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title())
|
t = re.sub("([a-z])'([A-Z])", lambda m: m.group(0).lower(), value.title())
|
||||||
|
return re.sub("\d([A-Z])", lambda m: m.group(0).lower(), t)
|
||||||
title.is_safe = True
|
title.is_safe = True
|
||||||
title = stringfilter(title)
|
title = stringfilter(title)
|
||||||
|
|
||||||
|
|
|
@ -120,13 +120,19 @@ def get_filter_tests():
|
||||||
|
|
||||||
# Notice that escaping is applied *after* any filters, so the string
|
# Notice that escaping is applied *after* any filters, so the string
|
||||||
# formatting here only needs to deal with pre-escaped characters.
|
# formatting here only needs to deal with pre-escaped characters.
|
||||||
'filter-stringformat01': ('{% autoescape off %}.{{ a|stringformat:"5s" }}. .{{ b|stringformat:"5s" }}.{% endautoescape %}', {"a": "a<b", "b": mark_safe("a<b")}, u". a<b. . a<b."),
|
'filter-stringformat01': ('{% autoescape off %}.{{ a|stringformat:"5s" }}. .{{ b|stringformat:"5s" }}.{% endautoescape %}',
|
||||||
'filter-stringformat02': ('.{{ a|stringformat:"5s" }}. .{{ b|stringformat:"5s" }}.', {"a": "a<b", "b": mark_safe("a<b")}, u". a<b. . a<b."),
|
{"a": "a<b", "b": mark_safe("a<b")}, u". a<b. . a<b."),
|
||||||
|
'filter-stringformat02': ('.{{ a|stringformat:"5s" }}. .{{ b|stringformat:"5s" }}.', {"a": "a<b", "b": mark_safe("a<b")},
|
||||||
|
u". a<b. . a<b."),
|
||||||
|
|
||||||
# XXX No test for "title" filter; needs an actual object.
|
# Test the title filter
|
||||||
|
'filter-title1' : ('{{ a|title }}', {'a' : 'JOE\'S CRAB SHACK'}, u'Joe's Crab Shack'),
|
||||||
|
'filter-title2' : ('{{ a|title }}', {'a' : '555 WEST 53RD STREET'}, u'555 West 53rd Street'),
|
||||||
|
|
||||||
'filter-truncatewords01': ('{% autoescape off %}{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}{% endautoescape %}', {"a": "alpha & bravo", "b": mark_safe("alpha & bravo")}, u"alpha & ... alpha & ..."),
|
'filter-truncatewords01': ('{% autoescape off %}{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}{% endautoescape %}',
|
||||||
'filter-truncatewords02': ('{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}', {"a": "alpha & bravo", "b": mark_safe("alpha & bravo")}, u"alpha & ... alpha & ..."),
|
{"a": "alpha & bravo", "b": mark_safe("alpha & bravo")}, u"alpha & ... alpha & ..."),
|
||||||
|
'filter-truncatewords02': ('{{ a|truncatewords:"2" }} {{ b|truncatewords:"2"}}',
|
||||||
|
{"a": "alpha & bravo", "b": mark_safe("alpha & bravo")}, u"alpha & ... alpha & ..."),
|
||||||
|
|
||||||
# The "upper" filter messes up entities (which are case-sensitive),
|
# The "upper" filter messes up entities (which are case-sensitive),
|
||||||
# so it's not safe for non-escaping purposes.
|
# so it's not safe for non-escaping purposes.
|
||||||
|
|
Loading…
Reference in New Issue