mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 12:32:14 +09:00
Fix fatal error in some environments when relative URL is passed to encodeIdna() or decodeIdna() #2675
This commit is contained in:
parent
1199095e7f
commit
5834a3c18a
1 changed files with 10 additions and 2 deletions
|
|
@ -207,9 +207,13 @@ class URL
|
||||||
*/
|
*/
|
||||||
public static function encodeIdna(string $url): string
|
public static function encodeIdna(string $url): string
|
||||||
{
|
{
|
||||||
if (preg_match('@[:/#]@', $url))
|
if (preg_match('@[:/#]@', $url) && !str_starts_with($url, '/'))
|
||||||
{
|
{
|
||||||
$domain = parse_url($url, \PHP_URL_HOST);
|
$domain = parse_url($url, \PHP_URL_HOST);
|
||||||
|
if (!$domain)
|
||||||
|
{
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
$position = strpos($url, $domain);
|
$position = strpos($url, $domain);
|
||||||
if ($position === false)
|
if ($position === false)
|
||||||
{
|
{
|
||||||
|
|
@ -243,9 +247,13 @@ class URL
|
||||||
*/
|
*/
|
||||||
public static function decodeIdna(string $url): string
|
public static function decodeIdna(string $url): string
|
||||||
{
|
{
|
||||||
if (preg_match('@[:/#]@', $url))
|
if (preg_match('@[:/#]@', $url) && !str_starts_with($url, '/'))
|
||||||
{
|
{
|
||||||
$domain = parse_url($url, \PHP_URL_HOST);
|
$domain = parse_url($url, \PHP_URL_HOST);
|
||||||
|
if (!$domain)
|
||||||
|
{
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
$position = strpos($url, $domain);
|
$position = strpos($url, $domain);
|
||||||
if ($position === false)
|
if ($position === false)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue