Skip to content

Commit 0c637e5

Browse files
committed
:octocat:
1 parent e4cd15a commit 0c637e5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/BBCode.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,13 @@ protected function parseBBCode($bbcode):string{
271271
protected function parseAttributes(string $attributes):array{
272272
$attr = [];
273273

274+
if(empty($attributes)){
275+
return $attr;
276+
}
277+
274278
// @todo: fix attributes pattern: accept single and double quotes around the value
275-
if(preg_match_all('#(?<name>^|\w+)\=(\'?)(?<value>[^\']*?)\2(?: |$)#', $attributes, $matches, PREG_SET_ORDER) > 0){
279+
if(preg_match_all('#(?<name>^|[[a-z]+)\=(["\']?)(?<value>[^"\']*?)\2(?: |$)#i', $attributes, $matches, PREG_SET_ORDER) > 0){
280+
print_r(['$attributes' => $attributes, '$matches' => $matches]);
276281

277282
foreach($matches as $attribute){
278283
$name = empty($attribute['name']) ? $this->options->placeholder_bbtag : strtolower(trim($attribute['name']));
@@ -285,6 +290,7 @@ protected function parseAttributes(string $attributes):array{
285290

286291
if($e !== PREG_NO_ERROR){
287292
$this->logger->debug('preg_error', ['errno' => $e, '$attributes' => $attributes]);
293+
$attr['__error__'] = $attributes;
288294
}
289295

290296
return $attr;

0 commit comments

Comments
 (0)