diff --git a/composer.lock b/composer.lock index b41a4fa..814eb72 100644 --- a/composer.lock +++ b/composer.lock @@ -1582,16 +1582,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v5.4.34", + "version": "v5.4.35", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "e3bca343efeb613f843c254e7718ef17c9bdf7a3" + "reference": "7a69a85c7ea5bdd1e875806a99c51a87d3a74b38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/e3bca343efeb613f843c254e7718ef17c9bdf7a3", - "reference": "e3bca343efeb613f843c254e7718ef17c9bdf7a3", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/7a69a85c7ea5bdd1e875806a99c51a87d3a74b38", + "reference": "7a69a85c7ea5bdd1e875806a99c51a87d3a74b38", "shasum": "" }, "require": { @@ -1647,7 +1647,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.34" + "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.35" }, "funding": [ { @@ -1663,7 +1663,7 @@ "type": "tidelift" } ], - "time": "2023-12-27T21:12:56+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -1746,16 +1746,16 @@ }, { "name": "symfony/finder", - "version": "v5.4.27", + "version": "v5.4.35", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ff4bce3c33451e7ec778070e45bd23f74214cd5d" + "reference": "abe6d6f77d9465fed3cd2d029b29d03b56b56435" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ff4bce3c33451e7ec778070e45bd23f74214cd5d", - "reference": "ff4bce3c33451e7ec778070e45bd23f74214cd5d", + "url": "https://api.github.com/repos/symfony/finder/zipball/abe6d6f77d9465fed3cd2d029b29d03b56b56435", + "reference": "abe6d6f77d9465fed3cd2d029b29d03b56b56435", "shasum": "" }, "require": { @@ -1789,7 +1789,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.27" + "source": "https://github.com/symfony/finder/tree/v5.4.35" }, "funding": [ { @@ -1805,20 +1805,20 @@ "type": "tidelift" } ], - "time": "2023-07-31T08:02:31+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -1832,9 +1832,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1871,7 +1868,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -1887,20 +1884,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -1914,9 +1911,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1954,7 +1948,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -1970,20 +1964,20 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "shasum": "" }, "require": { @@ -1991,9 +1985,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -2037,7 +2028,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" }, "funding": [ { @@ -2053,20 +2044,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b" + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/7581cd600fa9fd681b797d00b02f068e2f13263b", - "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/c565ad1e63f30e7477fc40738343c62b40bc672d", + "reference": "c565ad1e63f30e7477fc40738343c62b40bc672d", "shasum": "" }, "require": { @@ -2074,9 +2065,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -2116,7 +2104,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.29.0" }, "funding": [ { @@ -2132,20 +2120,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/yaml", - "version": "v5.4.31", + "version": "v5.4.35", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "f387675d7f5fc4231f7554baa70681f222f73563" + "reference": "e78db7f5c70a21f0417a31f414c4a95fe76c07e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/f387675d7f5fc4231f7554baa70681f222f73563", - "reference": "f387675d7f5fc4231f7554baa70681f222f73563", + "url": "https://api.github.com/repos/symfony/yaml/zipball/e78db7f5c70a21f0417a31f414c4a95fe76c07e4", + "reference": "e78db7f5c70a21f0417a31f414c4a95fe76c07e4", "shasum": "" }, "require": { @@ -2191,7 +2179,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v5.4.31" + "source": "https://github.com/symfony/yaml/tree/v5.4.35" }, "funding": [ { @@ -2207,7 +2195,7 @@ "type": "tidelift" } ], - "time": "2023-11-03T14:41:28+00:00" + "time": "2024-01-23T13:51:25+00:00" }, { "name": "twig/twig", diff --git a/system/typemill/Extensions/ParsedownExtension.php b/system/typemill/Extensions/ParsedownExtension.php index 22fe2d6..16509d9 100644 --- a/system/typemill/Extensions/ParsedownExtension.php +++ b/system/typemill/Extensions/ParsedownExtension.php @@ -760,7 +760,44 @@ class ParsedownExtension extends \ParsedownExtra { if ($this->dispatcher && preg_match('/^\[:.*:\]/', $Line['text'], $matches)) { - return $this->createShortcodeArray($matches,$block = true); + if(is_array($this->allowedShortcodes) && empty($this->allowedShortcodes)) + { + return array('element' => array()); + } + + $shortcodeString = substr($matches[0], 2, -2); + $shortcodeArray = explode(' ', $shortcodeString, 2); + $shortcode = []; + + $shortcode['name'] = $shortcodeArray[0]; + $shortcode['params'] = false; + + if(is_array($this->allowedShortcodes) && !in_array($shortcode['name'], $this->allowedShortcodes)) + { + return array('element' => array()); + } + + $params = $this->shortcodeParams($shortcodeArray); + if($params) + { + $shortcode['params'] = $params; + } + + $html = $this->dispatcher->dispatch(new OnShortcodeFound($shortcode), 'onShortcodeFound')->getData(); + + # if no shortcode has been processed, add the original string + if(is_array($html) OR is_object($html)) + { + $html = '

No shortcode found.

'; + } + + return array( + 'element' => array( + 'rawHtml' => $html, + 'allowRawHtmlInSafeMode' => true, + ), + 'extent' => strlen($matches[0]), + ); } else { @@ -772,9 +809,46 @@ class ParsedownExtension extends \ParsedownExtra { $remainder = $Excerpt['text']; - if ($this->dispatcher && preg_match('/\[:.*:\]/', $remainder, $matches)) + if ($this->dispatcher && preg_match('/\[:.*?:\]/', $remainder, $matches)) { - return $this->createShortcodeArray($matches, $block = false); + if(is_array($this->allowedShortcodes) && empty($this->allowedShortcodes)) + { + return array('element' => array()); + } + + $shortcodeString = substr($matches[0], 2, -2); + $shortcodeArray = explode(' ', $shortcodeString, 2); + $shortcode = []; + + $shortcode['name'] = $shortcodeArray[0]; + $shortcode['params'] = false; + + if(is_array($this->allowedShortcodes) && !in_array($shortcode['name'], $this->allowedShortcodes)) + { + return array('element' => array()); + } + + $params = $this->shortcodeParams($shortcodeArray); + if($params) + { + $shortcode['params'] = $params; + } + + $html = $this->dispatcher->dispatch(new OnShortcodeFound($shortcode), 'onShortcodeFound')->getData(); + + # if no shortcode has been processed, add the original string + if(is_array($html) OR is_object($html)) + { + $html = 'No shortcode found.'; + } + + return array( + 'element' => array( + 'rawHtml' => $html, + 'allowRawHtmlInSafeMode' => true, + ), + 'extent' => strlen($matches[0]), + ); } else { @@ -789,29 +863,11 @@ class ParsedownExtension extends \ParsedownExtra $this->allowedShortcodes = $shortcodelist; } - protected function createShortcodeArray($matches, $block) + protected function shortcodeParams($shortcodeArray) { - if(is_array($this->allowedShortcodes) && empty($this->allowedShortcodes)) - { - return array('element' => array()); - } - - $shortcodeString = substr($matches[0], 2, -2); - $shortcodeArray = explode(' ', $shortcodeString, 2); - $shortcode = []; - - $shortcode['name'] = $shortcodeArray[0]; - $shortcode['params'] = false; - - if(is_array($this->allowedShortcodes) && !in_array($shortcode['name'], $this->allowedShortcodes)) - { - return array('element' => array()); - } - - # are there params? if(isset($shortcodeArray[1])) { - $shortcode['params'] = []; + $params = []; # see: https://www.thetopsites.net/article/58136180.shtml $pattern = '/(\\w+)\s*=\\s*("[^"]*"|\'[^\']*\'|[^"\'\\s>]*)/'; @@ -821,33 +877,14 @@ class ParsedownExtension extends \ParsedownExtra { if(isset($attribute[1]) && isset($attribute[2])) { - $shortcode['params'][$attribute[1]] = trim($attribute[2], " \""); + $params[$attribute[1]] = trim($attribute[2], " \""); } } + + return $params; } - $html = $this->dispatcher->dispatch(new OnShortcodeFound($shortcode), 'onShortcodeFound')->getData(); - - # if no shortcode has been processed, add the original string - if(is_array($html) OR is_object($html)) - { - if($block) - { - $html = '

No shortcode found.

'; - } - else - { - $html = 'No shortcode found.'; - } - } - - return array( - 'element' => array( - 'rawHtml' => $html, - 'allowRawHtmlInSafeMode' => true, - ), - 'extent' => strlen($matches[0]), - ); + return false; } protected function inlineLink($Excerpt) diff --git a/system/typemill/settings/defaults.yaml b/system/typemill/settings/defaults.yaml index a09f4d6..d11370c 100644 --- a/system/typemill/settings/defaults.yaml +++ b/system/typemill/settings/defaults.yaml @@ -1,4 +1,4 @@ -version: '2.1.2' +version: '2.2.0' title: 'Typemill' author: 'Unknown' copyright: false