Added URL validation for social buttons
This commit is contained in:
parent
c363cd5153
commit
d5be0c0cdb
1 changed files with 17 additions and 0 deletions
|
@ -49,6 +49,18 @@ class Site extends dbJSON {
|
|||
'markdownParser'=> true,
|
||||
'customFields'=> '{}'
|
||||
);
|
||||
private $linkKeys = array(
|
||||
'twitter',
|
||||
'facebook',
|
||||
'codepen',
|
||||
'instagram',
|
||||
'github',
|
||||
'gitlab',
|
||||
'linkedin',
|
||||
'mastodon',
|
||||
'dribbble',
|
||||
'vk'
|
||||
);
|
||||
|
||||
function __construct()
|
||||
{
|
||||
|
@ -74,6 +86,11 @@ class Site extends dbJSON {
|
|||
if (isset($args[$field])) {
|
||||
$finalValue = Sanitize::html($args[$field]);
|
||||
$finalValue = Sanitize::noJSLink($finalValue);
|
||||
if (in_array($field,$this->linkKeys)){
|
||||
if (!filter_var($finalValue, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED)) {
|
||||
$finalValue = "";
|
||||
}
|
||||
}
|
||||
if ($finalValue==='false') { $finalValue = false; }
|
||||
elseif ($finalValue==='true') { $finalValue = true; }
|
||||
settype($finalValue, gettype($value));
|
||||
|
|
Loading…
Add table
Reference in a new issue