While working on #200185: truncate_utf8() is used as a substring function I came across this piece of code (in _comment_form_submit()):
$comment_values['subject'] = trim(truncate_utf8(decode_entities(strip_tags(check_markup($comment_values['comment'], $comment_values['comment_format']))), 29, TRUE));
And while nothing is functionally wrong with that, it just seems to me that it would be smarter to trim() before truncating, as 1) truncate_utf8() doesn't (and shouldn't) append or prepend any whitespace to the string given, and 2) if the string sent to truncate_utf8() is already trim()'ed, there is just a bit slighter chance of truncate_utf8() actually truncating the string - and even if it does, it won't use the whitespace that is being removed anyway as grounds for its truncating.

This applies to 7.x, 6.x, and 5.x. And patches provided for each. :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch failed testing.

Freso’s picture

Status: Needs work » Needs review

... That is hardly the fault of this patch.

Status: Needs review » Needs work

The last submitted patch failed testing.

Freso’s picture

Status: Needs work » Needs review

Apparently test node #16 has gone bonkers, so still keeping my claim that this is not the fault of this patch. :)

catch’s picture

Status: Needs review » Reviewed & tested by the community
Dries’s picture

Version: 7.x-dev » 6.x-dev

Committed to CVS HEAD. Thanks!

Gábor Hojtsy’s picture

Version: 6.x-dev » 5.x-dev

Thanks, committed to Drupal 6 too. Moving to 5.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 5.x.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.