Opened 10 years ago

Closed 7 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: master
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


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

<a class="offsite" href=

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 10 years ago.
Handle mutli-line tags
10931-utils_text-r10651.patch (4.2 KB) - added by George Song 10 years ago.
Updated patch with tests.
10931-3.diff (1.4 KB) - added by Claude Paroz 7 years ago.
Updated to current trunk

Download all attachments as: .zip

Change History (11)

Changed 10 years ago by George Song

Attachment: utils_text-r10637.patch added

Handle mutli-line tags

comment:1 Changed 10 years ago by Chris Beaven

Needs tests: set
Triage Stage: UnreviewedAccepted

comment:2 Changed 10 years ago by George Song

Owner: changed from nobody to George Song
Status: newassigned

Changed 10 years ago by George Song

Updated patch with tests.

comment:3 Changed 10 years ago by George Song

Needs tests: unset

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

comment:4 Changed 10 years ago by George Song

Triage Stage: AcceptedReady for checkin

comment:5 Changed 9 years ago by Luke Plant

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/ Just add to the ones there already.


comment:6 Changed 8 years ago by Luke Plant

Severity: Normal
Type: Bug

Changed 7 years ago by Claude Paroz

Attachment: 10931-3.diff added

Updated to current trunk

comment:7 Changed 7 years ago by Claude Paroz

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

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

comment:8 Changed 7 years ago by Julien Phalip

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