Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick SAMA committed Apr 14, 2023
1 parent 01100c9 commit d9f666f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions var/Typecho/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static function maxLength(string $str, int $length): bool
*/
public static function email(string $str): bool
{
return filter_var($str, FILTER_VALIDATE_EMAIL) !== false;
return (bool) preg_match("/^[_a-z0-9-\.]+@([-a-z0-9]+\.)+[a-z]{2,}$/i", $str);
}

/**
Expand All @@ -110,10 +110,14 @@ public static function email(string $str): bool
*/
public static function url(string $str): bool
{
return filter_var(
$str,
FILTER_VALIDATE_URL
) !== false;
$parts = @parse_url($str);
if (!$parts) {
return false;
}

return isset($parts['scheme']) &&
in_array($parts['scheme'], array('http', 'https', 'ftp')) &&
!preg_match('/(\(|\)|\\\|"|<|>|[\x00-\x08]|[\x0b-\x0c]|[\x0e-\x19])/', $str);
}

/**
Expand Down

0 comments on commit d9f666f

Please sign in to comment.