diff --git a/src/Data/Validator.php b/src/Data/Validator.php index c566d1ebeb..511a696bc2 100644 --- a/src/Data/Validator.php +++ b/src/Data/Validator.php @@ -80,8 +80,8 @@ public function sanitize($input, $allowableTags = [], $utf8_encode = true) // Check allowable fields for URLs foreach ($allowableTags as $field => $value) { - if (is_string($value) && (strtoupper($value) == 'URL' || strtoupper($value) == 'PATH')) { - $urls[$field] = strtoupper($value) == 'URL'; + if (is_string($value) && strtoupper($value) == 'URL') { + $urls[$field] = $field; } } @@ -98,10 +98,10 @@ public function sanitize($input, $allowableTags = [], $utf8_encode = true) $value = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $value); $value = preg_replace('/\\\\+0+/', '', $value); - if (isset($urls[$field])) { + if (!empty($urls[$field])) { // Sanitize URL - $value = $this->sanitizeUrl($value, $urls[$field]); - } elseif (isset($allowableTags[$field])) { + $value = $this->sanitizeUrl($value); + } elseif (!empty($allowableTags[$field])) { // Sanitize HTML if (strtoupper($allowableTags[$field]) == 'RAW') { $output[$field] = $value; @@ -194,7 +194,7 @@ public function sanitizeRichText($value) * @param string $url * @return string */ - public function sanitizeUrl($url, $protocol = true) + public function sanitizeUrl($url) { if ($url === '') return $url; @@ -205,7 +205,7 @@ public function sanitizeUrl($url, $protocol = true) $url = str_replace("'", ''', $url); // If there is no protocol, add a default one - if ($protocol && mb_stripos($url, '://') === false) { + if (mb_stripos($url, '://') === false) { $url = 'https://'.$url; } diff --git a/src/Forms/Input/FileUpload.php b/src/Forms/Input/FileUpload.php index 0a57e3d801..92e175b752 100644 --- a/src/Forms/Input/FileUpload.php +++ b/src/Forms/Input/FileUpload.php @@ -22,7 +22,6 @@ namespace Gibbon\Forms\Input; use Gibbon\Services\Format; -use Gibbon\Data\Validator; /** * TextField @@ -197,14 +196,12 @@ protected function getElement() foreach ($this->attachments as $attachmentName => $attachmentPath) { - $attachmentPath = (new Validator(''))->sanitizeUrl($attachmentPath, false); - if (!empty($attachmentPath)) { $output .= '