From 10e8fc50d3ae1a282aa5789bdd6b119888728af0 Mon Sep 17 00:00:00 2001 From: im-mi Date: Thu, 1 Sep 2016 03:23:52 -0400 Subject: [PATCH] Fix "starts-with" header in tag list when escaping required This fixes the "starts-with" headers* on the tags/alphabetic page. Before, the headers would be wrong if they started with an escaped character. This also escapes the resulting header so that it no longer generates invalid HTML in such cases. * Note that these headers are only visible when paged tag lists is disabled. --- ext/tag_list/main.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index aff12bb6..c97ebac4 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -297,13 +297,15 @@ class TagList extends Extension { $lastLetter = ""; foreach($tag_data as $row) { - $h_tag = html_escape($row['tag']); - $count = $row['count']; - if($lastLetter != mb_strtolower(substr($h_tag, 0, count($starts_with)+1))) { - $lastLetter = mb_strtolower(substr($h_tag, 0, count($starts_with)+1)); - $html .= "

$lastLetter
"; + $tag = $row['tag']; + if($lastLetter != mb_strtolower(substr($tag, 0, count($starts_with)+1))) { + $lastLetter = mb_strtolower(substr($tag, 0, count($starts_with)+1)); + $h_lastLetter = html_escape($lastLetter); + $html .= "

$h_lastLetter
"; } - $link = $this->tag_link($row['tag']); + $link = $this->tag_link($tag); + $h_tag = html_escape($tag); + $count = $row['count']; $html .= "$h_tag ($count)\n"; }