-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
hi there - noticed that if the IDN hostname is also in the URI, it also gets encoded.
example/test:
https://палочка.ru/foo+палочка+bar
enc-> https://xn--80aa3adpd3d.ru/foo+xn--80aa3adpd3d+bar
dec-> https://палочка.ru/foo+палочка+bar
While the decode does do the proper thing, the encoded value will be broken. Simple fix to limit to host:
private static function urlendecode($url, $func) {
$uri = parse_url($url);
+ $mod = FALSE;
if (!empty($uri['host'])) {
foreach (array_unique((array)explode('.', $uri['host'])) as $var) {
if (($encoded = self::$func($var)) != $var) {
- $url = str_replace($var, $encoded, $url);
+ $uri['host'] = str_replace($var, $encoded, $uri['host']);
+ $mod = TRUE;
}
}
+ // rebuild the URL from parsed parts
+ if ($mod) $url = http_build_url($uri);
}
return $url;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels