parsedown
parsedown copied to clipboard
Bug: Uninitialized string offset: 1
When my text contains: &
in the header it returns an error. My Parsedown version is 1.8.0-beta-7
protected function inlineSpecialCharacter($Excerpt)
{
if ($Excerpt['text'][1] !== ' ' and strpos($Excerpt['text'], ';') !== false
and preg_match('/^&(#?+[0-9a-zA-Z]++);/', $Excerpt['text'], $matches)
) {
return array(
'element' => array('rawHtml' => '&' . $matches[1] . ';'),
'extent' => strlen($matches[0]),
);
}
return;
}
I solved it by overwriting the function
if (isset($Excerpt['text'][1] ) && $Excerpt['text'][1] !== ' ' and strpos($Excerpt['text'], ';') !== false
and preg_match('/^&(#?+[0-9a-zA-Z]++);/', $Excerpt['text'], $matches)
)
...
But please fix this issue.
I am also getting this same PHP Notice.