From: Matthew Exon Date: Mon, 30 Jan 2017 15:48:12 +0000 (+0000) Subject: Break out list of acceptable protocols in "src" attribute into separate variable... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ce10a9aa7f97424caa3f2db5d5fd54a2da850ca3;p=friendica.git Break out list of acceptable protocols in "src" attribute into separate variable similar to "href" attributes --- diff --git a/include/bbcode.php b/include/bbcode.php index ab928bf12f..0f1a705faa 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -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 $Text = preg_replace('/\<([^>]*?)(src|href)=(.*?)\&\;(.*?)\>/ism', '<$1$2=$3&$4>', $Text); - // sanitizes src attributes (only relative redir URIs or http URLs) - $Text = preg_replace('#<([^>]*?)(src)="(?!http|redir|cid)(.*?)"(.*?)>#ism', '<$1$2=""$4 class="invalid-src" title="' . t('Invalid source protocol') . '">', $Text); + // sanitizes src attributes (http and redir URLs for displaying in a web page, cid used for inline images in emails) + $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) // default value for backward compatibility