Improve sanitizing functions for mail and url
This commit is contained in:
parent
55db406401
commit
f478728ab9
|
@ -145,10 +145,10 @@ final class MD_STD_IN {
|
|||
*/
|
||||
final public static function sanitize_url($input):string {
|
||||
|
||||
if ($input === "") return $input;
|
||||
if ($input === "") return "";
|
||||
|
||||
$output = \filter_var($input, FILTER_SANITIZE_URL);
|
||||
if (\filter_var($input, FILTER_VALIDATE_URL) === false) {
|
||||
if (\filter_var($output, FILTER_VALIDATE_URL) === false) {
|
||||
throw new MDInvalidUrl("Invalid input URL");
|
||||
}
|
||||
|
||||
|
@ -165,10 +165,10 @@ final class MD_STD_IN {
|
|||
*/
|
||||
final public static function sanitize_email($input):string {
|
||||
|
||||
if ($input === "") return $input;
|
||||
if ($input === "") return "";
|
||||
|
||||
$output = \filter_var($input, FILTER_SANITIZE_EMAIL);
|
||||
if (\filter_var($input, FILTER_VALIDATE_EMAIL) === false) {
|
||||
if (\filter_var($output, FILTER_VALIDATE_EMAIL) === false) {
|
||||
throw new MDInvalidEmail("Invalid input email address");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user