1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Optimise commonly used regexes to fail fast

This commit is contained in:
Aidan Woods 2018-04-08 20:43:14 +01:00
parent dc5cf8770b
commit d6e306d620
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -1218,12 +1218,12 @@ class Parsedown
if ($this->breaksEnabled)
{
$Inline['element']['rawHtml'] = preg_replace('/[ ]*\n/', "<br />\n", $safeText);
$Inline['element']['rawHtml'] = preg_replace('/[ ]*+\n/', "<br />\n", $safeText);
$Inline['element']['allowRawHtmlInSafeMode'] = true;
}
else
{
$Inline['element']['rawHtml'] = preg_replace('/(?:[ ][ ]+|[ ]*\\\\)\n/', "<br />\n", $safeText);
$Inline['element']['rawHtml'] = preg_replace('/(?:[ ]*+\\\\|[ ]{2,}+)\n/', "<br />\n", $safeText);
$Inline['element']['allowRawHtmlInSafeMode'] = true;
}