From bcef3fbc8ff86d7f072e0d552d1033e1f5ab9573 Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 29 Aug 2016 09:21:23 +0100 Subject: [PATCH] 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");