mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Sanity checks before starting regex engine
This commit is contained in:
parent
450a74fedf
commit
726d4ef44a
@ -829,8 +829,9 @@ class Parsedown
|
|||||||
|
|
||||||
protected function blockReference($Line)
|
protected function blockReference($Line)
|
||||||
{
|
{
|
||||||
if (preg_match('/^\[(.+?)\]:[ ]*+<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*+$/', $Line['text'], $matches))
|
if (strpos($Line['text'], ']') !== false
|
||||||
{
|
and preg_match('/^\[(.+?)\]:[ ]*+<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*+$/', $Line['text'], $matches)
|
||||||
|
) {
|
||||||
$id = strtolower($matches[1]);
|
$id = strtolower($matches[1]);
|
||||||
|
|
||||||
$Data = array(
|
$Data = array(
|
||||||
@ -1448,8 +1449,9 @@ class Parsedown
|
|||||||
|
|
||||||
protected function inlineSpecialCharacter($Excerpt)
|
protected function inlineSpecialCharacter($Excerpt)
|
||||||
{
|
{
|
||||||
if (preg_match('/^&(#?+[0-9a-zA-Z]++);/', $Excerpt['text'], $matches))
|
if ($Excerpt['text'][1] !== ' ' and strpos($Excerpt['text'], ';') !== false
|
||||||
{
|
and preg_match('/^&(#?+[0-9a-zA-Z]++);/', $Excerpt['text'], $matches)
|
||||||
|
) {
|
||||||
return array(
|
return array(
|
||||||
'element' => array('rawHtml' => "&{$matches[1]};"),
|
'element' => array('rawHtml' => "&{$matches[1]};"),
|
||||||
'extent' => strlen($matches[0]),
|
'extent' => strlen($matches[0]),
|
||||||
@ -1489,8 +1491,9 @@ class Parsedown
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE))
|
if (strpos($Excerpt['context'], 'http') !== false
|
||||||
{
|
and preg_match('/\bhttps?+:[\/]{2}[^\s<]+\b\/*+/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)
|
||||||
|
) {
|
||||||
$url = $matches[0][0];
|
$url = $matches[0][0];
|
||||||
|
|
||||||
$Inline = array(
|
$Inline = array(
|
||||||
|
Loading…
Reference in New Issue
Block a user