From bcef3fbc8ff86d7f072e0d552d1033e1f5ab9573 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 29 Aug 2016 09:21:23 +0100 Subject: [PATCH 01/36] have tag sanitisation process ignore tags which are too long, fixes #565 --- core/imageboard.pack.php | 5 +++++ ext/tag_edit/test.php | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index b619f3d5..0827b411 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -1102,6 +1102,11 @@ class Tag { $tag = preg_replace("/^(\.+[\/\\\\])+/", "", $tag); # trailing slashes? $tag = trim($tag, ", \t\n\r\0\x0B"); + if(mb_strlen($tag, 'UTF-8') > 255){ + flash_message("The tag below is longer than 255 characters, please use a shorter tag.\n$tag\n"); + continue; + } + if(!empty($tag)) { $tag_array[] = $tag; } diff --git a/ext/tag_edit/test.php b/ext/tag_edit/test.php index 498d29f4..8099a702 100644 --- a/ext/tag_edit/test.php +++ b/ext/tag_edit/test.php @@ -21,6 +21,13 @@ class TagEditTest extends ShimmiePHPUnitTestCase { $this->log_out(); } + public function testTagEdit_tooLong() { + $this->log_in_as_user(); + $image_id = $this->post_image("tests/pbx_screenshot.jpg", str_repeat("a", 500)); + $this->get_page("post/view/$image_id"); + $this->assert_title("Image $image_id: tagme"); + } + public function testSourceEdit() { $this->log_in_as_user(); $image_id = $this->post_image("tests/pbx_screenshot.jpg", "pbx"); From bb64d12d9d71bb79d5ab0a57882353a09fd085af Mon Sep 17 00:00:00 2001 From: im-mi Date: Thu, 1 Sep 2016 00:35:52 -0400 Subject: [PATCH 02/36] Use TextFormattingEvent instead of raw BBCode formatter --- ext/pools/theme.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/pools/theme.php b/ext/pools/theme.php index 5edb3625..65194103 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -154,8 +154,9 @@ class PoolsTheme extends Themelet { } } - $bb = new BBCode(); - $page->add_block(new Block(html_escape($pool['title']), $bb->format($pool['description']), "main", 10)); + $tfe = new TextFormattingEvent($pool['description']); + send_event($tfe); + $page->add_block(new Block(html_escape($pool['title']), $tfe->formatted, "main", 10)); } } From 10e8fc50d3ae1a282aa5789bdd6b119888728af0 Mon Sep 17 00:00:00 2001 From: im-mi Date: Thu, 1 Sep 2016 03:23:52 -0400 Subject: [PATCH 03/36] 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"; } From b554e7505bda81b4a9417982f5fa6e1647e2b1e4 Mon Sep 17 00:00:00 2001 From: im-mi Date: Thu, 1 Sep 2016 21:57:53 -0400 Subject: [PATCH 04/36] Added zoom support to webm --- ext/handle_video/theme.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/handle_video/theme.php b/ext/handle_video/theme.php index 159283b1..171582d5 100644 --- a/ext/handle_video/theme.php +++ b/ext/handle_video/theme.php @@ -42,7 +42,12 @@ class VideoFileHandlerTheme extends Themelet { $html .= $html_fallback; } else { $html .= " -