From 0ab4251ab48c688b9426be4c79e3645d255ee16c Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Tue, 21 Apr 2020 07:20:35 +0200 Subject: [PATCH 01/11] Adds .webp images to allowed upload mime-types #372 --- CHANGELOG.md | 9 +++++++++ config/saito_config.php | 1 + 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35927e7cd..8d6fb91a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ - Δ Changed - − Removed +## [next] - + +- [Full commit-log](https://github.com/Schlaefer/Saito/compare/5.7.0...) +- [Download release-zip](https://github.com/Schlaefer/Saito/releases/download/saito-release-master-.zip) + +### Changes + +- + Adds .webp images to allowed upload mime-types #372 + ## [5.7.0] - 2020-03-25 - [Full commit-log](https://github.com/Schlaefer/Saito/compare/5.6.0...5.7.0) diff --git a/config/saito_config.php b/config/saito_config.php index 75b741cef..34dff43af 100644 --- a/config/saito_config.php +++ b/config/saito_config.php @@ -123,6 +123,7 @@ ->addType('image/jpeg', '19MB') ->addType('image/png', '19MB') ->addType('image/svg+xml') + ->addType('image/webp') ->addType('text/plain') ->addType('video/mp4') ->addType('video/webm'); From 5c77d43cae1d8b9b60369298770ec6d5cdc336b7 Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Tue, 21 Apr 2020 08:13:02 +0200 Subject: [PATCH 02/11] Fix Thread Collpase user setting not working in 5.x #371 --- CHANGELOG.md | 1 + src/View/Helper/JsDataHelper.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d6fb91a0..1d0dea7d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Changes - + Adds .webp images to allowed upload mime-types #372 +- ✓ Fixes Thread Collpase user setting not working in 5.x #371 ## [5.7.0] - 2020-03-25 diff --git a/src/View/Helper/JsDataHelper.php b/src/View/Helper/JsDataHelper.php index 0398e679a..b0210d9c8 100644 --- a/src/View/Helper/JsDataHelper.php +++ b/src/View/Helper/JsDataHelper.php @@ -74,7 +74,7 @@ public function getAppJs(View $View, ForumsUserInterface $CurrentUser) 'msg' => $this->notifications()->getAll(), 'request' => [ 'action' => $request->getParam('action'), - 'controller' => $request->getParam('controller'), + 'controller' => mb_strtolower($request->getParam('controller')), 'isMobile' => $request->is('mobile'), 'csrf' => $this->_getCsrf($View), ], From 86b1c6ca4d2389559a66418152436b09d524d6ff Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Tue, 21 Apr 2020 08:45:56 +0200 Subject: [PATCH 03/11] Fixes URL with paranthesis pair omits closing on autolink #373 --- CHANGELOG.md | 1 + .../Visitors/JbbCodeAutolinkVisitor.php | 21 ++++++++++-- .../tests/TestCase/Lib/BbcodeParserTest.php | 32 +++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d0dea7d2..79d4eca51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - + Adds .webp images to allowed upload mime-types #372 - ✓ Fixes Thread Collpase user setting not working in 5.x #371 +- ✓ Fixes URL with paranthesis pair omits closing on autolink #373 ## [5.7.0] - 2020-03-25 diff --git a/plugins/BbcodeParser/src/Lib/jBBCode/Visitors/JbbCodeAutolinkVisitor.php b/plugins/BbcodeParser/src/Lib/jBBCode/Visitors/JbbCodeAutolinkVisitor.php index da18a22da..00516e059 100644 --- a/plugins/BbcodeParser/src/Lib/jBBCode/Visitors/JbbCodeAutolinkVisitor.php +++ b/plugins/BbcodeParser/src/Lib/jBBCode/Visitors/JbbCodeAutolinkVisitor.php @@ -108,19 +108,34 @@ protected function atUserLink(string $string): string protected function autolink(string $string): string { $replace = function (array $matches): string { - // don't link locally + /// don't link locally if (strpos($matches['element'], 'file://') !== false) { return $matches['element']; } - // exclude punctuation at end of sentence from URLs + /// exclude punctuation at end of sentence from URLs $ignoredEndChars = implode('|', [',', '\?', ',', '\.', '\)', '!']); preg_match( '/(?P.*?)(?P' . $ignoredEndChars . ')?$/', $matches['element'], $m ); - // keep ['element'] and ['suffix'] and include ['prefix']; (array) for phpstan + + /// exclude ignored end chars if paired in URL foo.com/bar_(baz) + if (!empty($m['suffix'])) { + $ignoredIfNotPaired = [ + ['open' => '(', 'close' => ')'], + ]; + foreach ($ignoredIfNotPaired as $pair) { + $isUnpaired = substr_count($m['element'], $pair['open']) > substr_count($m['element'], $pair['close']); + if ($isUnpaired) { + $m['element'] .= $m['suffix']; + unset($m['suffix']); + } + } + } + + /// keep ['element'] and ['suffix'] and include ['prefix']; (array) for phpstan $matches = (array)($m + $matches); if (strpos($matches['element'], '://') === false) { diff --git a/plugins/BbcodeParser/tests/TestCase/Lib/BbcodeParserTest.php b/plugins/BbcodeParser/tests/TestCase/Lib/BbcodeParserTest.php index fbee699b4..5887d5e00 100755 --- a/plugins/BbcodeParser/tests/TestCase/Lib/BbcodeParserTest.php +++ b/plugins/BbcodeParser/tests/TestCase/Lib/BbcodeParserTest.php @@ -650,6 +650,38 @@ public function testLinkAutoUrlWithinParentheses() ]; $result = $this->_Parser->parse($input); $this->assertHtml($expected, $result); + + $input = 'some (www.example.com/foo_(bar)) text'; + $expected = [ + 'some (', + 'a' => [ + 'class' => 'richtext-link truncate', + 'href' => 'http://www.example.com/foo_(bar)', + 'rel' => 'external', + 'target' => '_blank', + ], + 'http://www.example.com/foo_(bar)', + '/a', + ') text', + ]; + $result = $this->_Parser->parse($input); + $this->assertHtml($expected, $result); + + $input = 'some www.example.com/foo_(bar) text'; + $expected = [ + 'some ', + 'a' => [ + 'class' => 'richtext-link truncate', + 'href' => 'http://www.example.com/foo_(bar)', + 'rel' => 'external', + 'target' => '_blank', + ], + 'http://www.example.com/foo_(bar)', + '/a', + ' text', + ]; + $result = $this->_Parser->parse($input); + $this->assertHtml($expected, $result); } public function testLinkAutoSurroundingChars() From e7ab2fe3dc6be8662eca165b01b788bccddf84bd Mon Sep 17 00:00:00 2001 From: Schlaefer Date: Thu, 30 Jul 2020 06:43:36 +0200 Subject: [PATCH 04/11] Fixes delete category and move existing posts --- CHANGELOG.md | 1 + .../src/Controller/CategoriesController.php | 2 +- .../Admin/src/Template/Categories/delete.ctp | 1 + .../Controller/CategoriesControllerTest.php | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79d4eca51..3ffc39bdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - + Adds .webp images to allowed upload mime-types #372 - ✓ Fixes Thread Collpase user setting not working in 5.x #371 - ✓ Fixes URL with paranthesis pair omits closing on autolink #373 +- ✓ Fixes delete category and move existing posts ## [5.7.0] - 2020-03-25 diff --git a/plugins/Admin/src/Controller/CategoriesController.php b/plugins/Admin/src/Controller/CategoriesController.php index b1b63a3f1..69f6dafa6 100755 --- a/plugins/Admin/src/Controller/CategoriesController.php +++ b/plugins/Admin/src/Controller/CategoriesController.php @@ -186,7 +186,7 @@ public function delete($id) /* get categories for target