From 5b0a1d9b5a9c3fc288d8cfa389579152a8857069 Mon Sep 17 00:00:00 2001 From: Xavier Lacot Date: Tue, 13 Aug 2024 14:52:17 +0200 Subject: [PATCH] fixed the parser behavior for texts that contain curly braces --- src/Extension/Attributes/Util/AttributesHelper.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Extension/Attributes/Util/AttributesHelper.php b/src/Extension/Attributes/Util/AttributesHelper.php index 5fbbdea1c3..db499a50bd 100644 --- a/src/Extension/Attributes/Util/AttributesHelper.php +++ b/src/Extension/Attributes/Util/AttributesHelper.php @@ -23,8 +23,8 @@ */ final class AttributesHelper { - private const SINGLE_ATTRIBUTE = '\s*([.]-?[_a-z][^\s}]*|[#][^\s}]+|' . RegexHelper::PARTIAL_ATTRIBUTENAME . RegexHelper::PARTIAL_ATTRIBUTEVALUESPEC . '?)\s*'; - private const ATTRIBUTE_LIST = '/^{:?(' . self::SINGLE_ATTRIBUTE . ')+}(?!})/i'; + private const SINGLE_ATTRIBUTE = '\s*([.]-?[_a-z][^\s}]*|[#][^\s}]+|' . RegexHelper::PARTIAL_ATTRIBUTENAME . RegexHelper::PARTIAL_ATTRIBUTEVALUESPEC . ')\s*'; + private const ATTRIBUTE_LIST = '/^{:?(' . self::SINGLE_ATTRIBUTE . ')+}/i'; /** * @return array @@ -72,14 +72,8 @@ public static function parseAttributes(Cursor $cursor): array continue; } - $parts = \explode('=', $attribute, 2); - if (\count($parts) === 1) { - $attributes[$attribute] = true; - continue; - } - /** @psalm-suppress PossiblyUndefinedArrayOffset */ - [$name, $value] = $parts; + [$name, $value] = \explode('=', $attribute, 2); $first = $value[0]; $last = \substr($value, -1);