Commit a5faf06c authored by Kevin Ditscheid's avatar Kevin Ditscheid

[BUGFIX] Fix given empty prefix

parent 0b8542b6
......@@ -55,11 +55,11 @@ class SpanParserService extends AbstractParserService {
*/
public function parse($content) {
$matches = [];
$prefix = preg_quote($this->extensionConfiguration['prefix'], '/');
$prefix = (string) $this->extensionConfiguration['prefix'];
$pattern = '/' .
'<span' . // This expression includes any span nodes and parses
'(?=[^>]+' . // any attributes of the beginning start tag.
'(?=(class="([^"]*?' . $prefix . '[^"]+?)"))' .
'(?=(class="([^"]*?' . preg_quote($prefix, '/') . '[^"]+?)"))' .
')' . // Use only spans which start with the defined class prefix
' (.*?)\1(.*?)>' . // and stop if the closing character is reached.
'(.*?)<\/span>' . // Finally we fetch the span content!
......@@ -75,8 +75,8 @@ class SpanParserService extends AbstractParserService {
foreach ($classes as $classIndex => $class) {
$class = trim($class);
if (FALSE !== strpos($class, $this->extensionConfiguration['prefix'])) {
$category = str_replace($this->extensionConfiguration['prefix'], '', $class);
if ($prefix !== '' && FALSE !== strpos($class, $prefix)) {
$category = str_replace($prefix, '', $class);
unset($classes[$classIndex]);
break;
}
......
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