mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 02:04:35 +02:00
Fix issue processwire/processwire-issues#1091
This commit is contained in:
@@ -1706,17 +1706,7 @@ class Sanitizer extends Wire {
|
||||
// if a scheme was added above (for filter_var validation) and it's not required, remove it
|
||||
$value = str_replace('http://', '', $value);
|
||||
}
|
||||
} else if($scheme == 'tel') {
|
||||
// tel: scheme is not supported by filter_var
|
||||
if(!preg_match('/^tel:\+?\d+$/', $value)) {
|
||||
$value = str_replace(' ', '', $value);
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
list($tel, $num) = explode(':', $value);
|
||||
$value = 'tel:';
|
||||
if(strpos($num, '+') === 0) $value .= '+';
|
||||
$value .= preg_replace('/[^\d]/', '', $num);
|
||||
}
|
||||
} else {
|
||||
} else if($scheme !== 'tel') {
|
||||
// URL already has a scheme
|
||||
$value = $this->filterValidateURL($value, $options);
|
||||
}
|
||||
@@ -1738,6 +1728,16 @@ class Sanitizer extends Wire {
|
||||
$domainPath = $this->text($domainPath, $textOptions);
|
||||
$value = $domainPath . (strlen($queryString) ? "?$queryString" : "");
|
||||
}
|
||||
|
||||
if($scheme === 'tel' && !preg_match('/^tel:\+?\d+$/', $value)) {
|
||||
// tel: scheme is not supported by filter_var
|
||||
$value = str_replace(' ', '', $value);
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
list($tel, $num) = explode(':', $value);
|
||||
$value = 'tel:';
|
||||
if(strpos($num, '+') === 0) $value .= '+';
|
||||
$value .= preg_replace('/[^\d]/', '', $num);
|
||||
}
|
||||
|
||||
if(!strlen($value)) return '';
|
||||
|
||||
|
Reference in New Issue
Block a user