mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Prevent various XSS attacks
This commit is contained in:
parent
4367f89a74
commit
1140613fc7
@ -75,6 +75,15 @@ class Parsedown
|
|||||||
|
|
||||||
protected $urlsLinked = true;
|
protected $urlsLinked = true;
|
||||||
|
|
||||||
|
function setSafeLinksEnabled($safeLinksEnabled)
|
||||||
|
{
|
||||||
|
$this->safeLinksEnabled = $safeLinksEnabled;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected $safeLinksEnabled = true;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Lines
|
# Lines
|
||||||
#
|
#
|
||||||
@ -1253,7 +1262,13 @@ class Parsedown
|
|||||||
$Element['attributes']['title'] = $Definition['title'];
|
$Element['attributes']['title'] = $Definition['title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$Element['attributes']['href'] = str_replace(array('&', '<'), array('&', '<'), $Element['attributes']['href']);
|
if ( $this->safeLinksEnabled && stripos($Element['attributes']['href'], 'javascript:') === 0 )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$Element['attributes']['href'] = htmlspecialchars($Element['attributes']['href']);
|
||||||
|
$Element['text'] = htmlspecialchars($Element['text']);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'extent' => $extent,
|
'extent' => $extent,
|
||||||
|
Loading…
Reference in New Issue
Block a user