Opened 16 years ago

Closed 13 years ago

#10931 closed Bug (fixed)

truncate_html_words doen't handle multi-line tags properly

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

Description

If you have the following in your HTML, for example:

<a class="offsite" href=
"http://blah.com/something/">

truncate_html_words will include all the words in the tag, as well as not close the tag properly if it needs to.

The attached patch simply adds the re.S flag for the two regular expressions used in the function.

Attachments (3)

utils_text-r10637.patch (683 bytes ) - added by George Song 16 years ago.
Handle mutli-line tags
10931-utils_text-r10651.patch (4.2 KB ) - added by George Song 16 years ago.
Updated patch with tests.
10931-3.diff (1.4 KB ) - added by Claude Paroz 13 years ago.
Updated to current trunk

Download all attachments as: .zip

Change History (11)

by George Song, 16 years ago

Attachment: utils_text-r10637.patch added

Handle mutli-line tags

comment:1 by Chris Beaven, 16 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

comment:2 by George Song, 16 years ago

Owner: changed from nobody to George Song
Status: newassigned

by George Song, 16 years ago

Updated patch with tests.

comment:3 by George Song, 16 years ago

Needs tests: unset

I've updated the patch with tests that are pretty comprehensive.

comment:4 by George Song, 15 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Luke Plant, 14 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

Thanks so much for this. However, the tests for this should be unit tests, as we are moving away from doctests, especially for this type of thing, and especially as there are already unit tests for truncate_html_words in tests/regressiontests/utils/tests.py. Just add to the ones there already.

Thanks.

comment:6 by Luke Plant, 14 years ago

Severity: Normal
Type: Bug

by Claude Paroz, 13 years ago

Attachment: 10931-3.diff added

Updated to current trunk

comment:7 by Claude Paroz, 13 years ago

Easy pickings: unset
Owner: George Song removed
Patch needs improvement: unset
Status: assignednew
UI/UX: unset

I only included the test that specifically addresses the new line issue.

comment:8 by Julien Phalip, 13 years ago

Owner: set to Julien Phalip
Resolution: fixed
Status: newclosed

In [17329]:

Fixed #10931 -- Made Truncator handle newlines properly. Thanks to gsong and Claude Paroz.

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