Opened 12 years ago

Closed 12 years ago

#19693 closed Bug (fixed)

truncatewords_html closes <br/> <hr/> tags

Reported by: sneawo Owned by: jonathanl
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: sneawo Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In [9]: ts = 'test<br/><hr/>test test'
In [10]: struncatewords_html(s, 2)
Out[10]: u'test<br/><hr/>test ...</hr/></br/>'

Change History (10)

comment:1 by sneawo, 12 years ago

Cc: sneawo added

comment:2 by sneawo, 12 years ago

Summary: trancatewords_html duplicates <br/> <hr/> tagstrancatewords_html closes <br/> <hr/> tags

comment:3 by reecelong, 12 years ago

Owner: changed from nobody to reecelong
Status: newassigned

comment:4 by reecelong, 12 years ago

Summary: trancatewords_html closes <br/> <hr/> tagstruncatewords_html closes <br/> <hr/> tags

comment:5 by sneawo, 12 years ago

I think it can be fixed with updating re_tag in django.utils.text
re_tag = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>')

comment:6 by reecelong, 12 years ago

Could you possibly provide more information about this bug? The current description of this bug is not clear enough for me to attempt to replicate. Thanks!

comment:7 by Aymeric Augustin, 12 years ago

The report isn't accurate; to reproduce on master:

>>> from django.template.defaultfilters import truncatewords_html
>>> truncatewords_html('test<br/><hr/>test test', 2)
u'test<br/><hr/>test ...</hr/></br/>'

comment:8 by Claude Paroz, 12 years ago

Triage Stage: UnreviewedAccepted

comment:9 by jonathanl, 12 years ago

Has patch: set
Owner: changed from reecelong to jonathanl
Version: 1.4master

Made a pull request https://github.com/django/django/pull/716

Thanks sneawo for your suggestion. It worked.

comment:10 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In ac4faa6dc33407c93566884e53fa5d8ef44c0a2a:

Fixed #19693 -- Made truncatewords_html handle self-closing tags

Thanks sneawo for the report and Jonathan Loy for the patch.

Note: See TracTickets for help on using tickets.
Back to Top