mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Added a workaround for a PHP bug caused by regex backtracking
fixes #443 by checking whether the required markers are avaialble in the text before applying the regex on it.
This commit is contained in:
parent
b70633df79
commit
e1b30621a9
@ -1120,11 +1120,11 @@ class Parsedown
|
||||
|
||||
$marker = $Excerpt['text'][0];
|
||||
|
||||
if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
|
||||
if ($Excerpt['text'][1] === $marker and strpos($Excerpt['text'], $marker . $marker, 2) !== false and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches))
|
||||
{
|
||||
$emphasis = 'strong';
|
||||
}
|
||||
elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
|
||||
elseif (strpos($Excerpt['text'], $marker, 1) !== false and preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches))
|
||||
{
|
||||
$emphasis = 'em';
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<p>example*
|
||||
<p>Without additional checks, this file causes a segfault in PHP < 7.0, which is caused by Regex Backtrack*
|
||||
example
|
||||
example
|
||||
example
|
||||
|
@ -1,4 +1,4 @@
|
||||
example*
|
||||
Without additional checks, this file causes a segfault in PHP < 7.0, which is caused by Regex Backtrack*
|
||||
example
|
||||
example
|
||||
example
|
||||
|
2549
test/data/dos2.html
Normal file
2549
test/data/dos2.html
Normal file
File diff suppressed because it is too large
Load Diff
2549
test/data/dos2.md
Normal file
2549
test/data/dos2.md
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user