From af2be14ccbbd30b781d76c2c4b005753d876e524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Sun, 26 Nov 2017 18:45:06 +0100 Subject: [PATCH] Fixed url parsing issues --- src/Pecee/Http/Uri.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Pecee/Http/Uri.php b/src/Pecee/Http/Uri.php index 0ab926c..41daf26 100644 --- a/src/Pecee/Http/Uri.php +++ b/src/Pecee/Http/Uri.php @@ -134,7 +134,15 @@ class Uri */ public function parseUrl($url, $component = -1) { - $parts = parse_url(urlencode($url), $component); + $encodedUrl = preg_replace_callback( + '%[^:/@?&=#]+%u', + function ($matches) { + return urlencode($matches[0]); + }, + $url + ); + + $parts = parse_url($encodedUrl, $component); if ($parts === false) { throw new \InvalidArgumentException('Malformed URL: ' . $url);