Break out list of acceptable protocols in "src" attribute into separate variable similar to "href" attributes
This commit is contained in:
parent
d99a96ef49
commit
ce10a9aa7f
|
@ -1163,8 +1163,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
||||||
// fix any escaped ampersands that may have been converted into links
|
// fix any escaped ampersands that may have been converted into links
|
||||||
$Text = preg_replace('/\<([^>]*?)(src|href)=(.*?)\&\;(.*?)\>/ism', '<$1$2=$3&$4>', $Text);
|
$Text = preg_replace('/\<([^>]*?)(src|href)=(.*?)\&\;(.*?)\>/ism', '<$1$2=$3&$4>', $Text);
|
||||||
|
|
||||||
// sanitizes src attributes (only relative redir URIs or http URLs)
|
// sanitizes src attributes (http and redir URLs for displaying in a web page, cid used for inline images in emails)
|
||||||
$Text = preg_replace('#<([^>]*?)(src)="(?!http|redir|cid)(.*?)"(.*?)>#ism', '<$1$2=""$4 class="invalid-src" title="' . t('Invalid source protocol') . '">', $Text);
|
$allowed_src_protocols = array('http', 'redir', 'cid');
|
||||||
|
$Text = preg_replace('#<([^>]*?)(src)="(?!' . implode('|', $allowed_src_protocols) . ')(.*?)"(.*?)>#ism',
|
||||||
|
'<$1$2=""$4 class="invalid-src" title="' . t('Invalid source protocol') . '">', $Text);
|
||||||
|
|
||||||
// sanitize href attributes (only whitelisted protocols URLs)
|
// sanitize href attributes (only whitelisted protocols URLs)
|
||||||
// default value for backward compatibility
|
// default value for backward compatibility
|
||||||
|
|
Loading…
Reference in a new issue