Commit 99c99b55 authored by Fabian Galinski's avatar Fabian Galinski

[BUGFIX] The custom parser dosen't take care of the keyword length.

parent ee1597da
......@@ -66,9 +66,16 @@ class CustomParserService extends AbstractParserService {
*/
public function parse($content) {
$matches = [];
$maximumLengthPattern = '+';
$maxParserKeywordLength = (int) $this->extensionConfiguration['maxParserKeywordLength'];
if ($maxParserKeywordLength > 0) {
$maximumLengthPattern = '{1,' . $maxParserKeywordLength . '}';
}
$prefix = preg_quote($this->extensionConfiguration['prefix'], '/');
$char = preg_quote($this->wrapCharacter, '/');
$pattern = '/' . $char . $prefix . '([^' . $char . ']+?)' .
$pattern = '/' . $char . $prefix . '([^' . $char . ']' . $maximumLengthPattern . '?)' .
$char . '(.+?)' . $char . $char . '/is';
preg_match_all($pattern, $content, $matches);
......
......@@ -13,4 +13,7 @@ plugin.tx_content_replacer {
# cat=plugin.tx_content_replacer//a; type=text; label= Special Parsing Wrap Character: If you want an own special non-html wrap, you can define the character. E.g. if you set ~ as character, the following wrap is possible: ~replace-category~term~~
specialParserCharacter =
# cat=plugin.tx_content_replacer//a; type=int; label= The maximum length of a parser keyword. The keyword is the word within the "specialParserCharacter".
maxParserKeywordLength = 0
}
......@@ -4,4 +4,5 @@ plugin.tx_content_replacer {
prefix = {$plugin.tx_content_replacer.prefix}
amountOfPasses = {$plugin.tx_content_replacer.amountOfPasses}
specialParserCharacter = {$plugin.tx_content_replacer.specialParserCharacter}
maxParserKeywordLength = {$plugin.tx_content_replacer.maxParserKeywordLength}
}
......@@ -4,7 +4,7 @@
"description": "You need a fast substitution of terms with full support of typoscript, categories and RTE integration? If yes, the extension could be perfectly fit into your project. The performance is gained by wrapping of the replacement terms to simplify the parsing process.",
"homepage": "https://www.sgalinski.de",
"license": ["GPL-2.0+"],
"version": "3.1.0",
"version": "3.1.1",
"support": {
"issues": "https://forge.typo3.org/projects/extension-content_replacer/issues"
},
......
......@@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = [
'title' => 'Content Replacer',
'description' => 'You need a fast substitution of terms with full support of typoscript, categories and RTE integration? If yes, the extension could be perfectly fit into your project. The performance is gained by wrapping of the replacement terms to simplify the parsing process.',
'category' => 'fe',
'version' => '3.1.0',
'version' => '3.1.1',
'state' => 'stable',
'uploadfolder' => FALSE,
'createDirs' => '',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment