Hello,

when one is searching for strings in admin/locale, HTML entities within the message strings are possibly cut off. (Text cut occurs within an entitiy, e.g. there's """ in the string and after the cut the string which is displayed ends with "&quo" e.g.)

This leads to invalid (X)HTML, which I just noticed using a theme which not only uses XHTML, but also sends "application/xhtml+xml" as MIME-Type for the document. (Therefore a browser capable of XHTML will stop displaying the site if there is an obvious syntax error.)

Regards,
Milan

CommentFileSizeAuthor
#4 locale_15121.patch1.25 KBwulff

Comments

jagdfalke’s picture

Ok, after having had this in the back of my head for some time, I thought that the simple fix would be to cut the string first, and apply htmlspecialchars then (since this function removes any entities, tags etc which would - when cut off - generate invalid markup, the problems is solved.)

To do this, change lines 1053/1054 of includes/locale.inc, which look like this:

      $source = htmlspecialchars($value['source']);
      $rows[] = array(array('data' => (strlen($source) > 150 ? substr($source, 0, 150) .'...' : $source) .'<br /><small>'. $value['location'] .'</small>'), array('data' => _locale_string_language_list($value['locales']), 'align' => 'center'), array('data' => l(t('edit'), "admin/locale/string/edit/$lid"), 'nowrap' => 'nowrap'), array('data' => l(t('delete'), "admin/locale/string/delete/$lid"), 'nowrap' => 'nowrap'));

to this:

      $source = htmlspecialchars(strlen($value['source']) > 150 ? substr($value['source'], 0, 150) .'...' : $value['source']);
      $rows[] = array(array('data' => $source .'<br /><small>'. $value['location'] .'</small>'), array('data' => _locale_string_language_list($value['locales']), 'align' => 'center'), array('data' => l(t('edit'), "admin/locale/string/edit/$lid"), 'nowrap' => 'nowrap'), array('data' => l(t('delete'), "admin/locale/string/delete/$lid"), 'nowrap' => 'nowrap'));

(the line numbers are valid for my Drupal 4.5.1.)

Regards,
Milan

killes@www.drop.org’s picture

Project: Locale » Drupal core
Version: master »
Component: Code » locale.module

If you set somethig to "patch" please include a patch file. Moving the issue to Drupal.

wulff’s picture

Version: » x.y.z

Still exists in current HEAD.

wulff’s picture

Status: Active » Needs review
StatusFileSize
new1.25 KB

Patch for jagdfalke's fix attached.

Steven’s picture

Status: Needs review » Fixed

Fixed in HEAD in a different way.

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)