erusev / parsedown-extra

Markdown Extra Extension for Parsedown
MIT License
822 stars 124 forks source link

Bug: Uninitialized string offset: 1 #157

Open hamedgasemi200 opened 4 years ago

hamedgasemi200 commented 4 years ago

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

protected function inlineSpecialCharacter($Excerpt)
{
if(!isset($Excerpt['text'][1])) return;
...