If string passed to truncate_utf8 contains tag, with attribute, truncate splits tag in middle of if, causing markup to fail. Example in dblog_overview, where message is split of 56 characters, <span class="foo"></span> can be split to <span ....

Comments

dawehner’s picture

If someone wants to truncate html strings http://api.drupal.org/api/function/text_summary/7 is the function to use.

Perhaps this function can be added to the filter api, so it can be used on other places, too, if you have disable the text module.

lyricnz’s picture

Status: Active » Closed (cannot reproduce)

truncate_utf8 doesn't claim to deal with HTML tags.

dblog_overview() itself doesn't truncate messages, that's done in theme_dblog_message() - but it does use:

truncate_utf8(filter_xss($output, array()), 56, TRUE, TRUE);

The filter_xss($output, array()) will remove all tags, so the risk identified in this issue cannot happy. Please reopen if this analysis is incorrect, and describe how to get truncated tags.