1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 02:04:35 +02:00
This commit is contained in:
Ryan Cramer
2020-02-21 12:10:24 -05:00
parent 32f068c5ea
commit 3670031682

View File

@@ -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 '';