summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2016-06-28 14:27:28 +0200
committerUrban Müller2016-06-28 14:27:28 +0200
commita165bf3c9b399456b9e411825e298cff5940efea (patch)
treef6f464ced0b2f33e7f8a84416fc0f78c3180e7b0
parent51eacd349ad58f74914fa3339fccdf53af59b6ce (diff)
downloaditools-a165bf3c9b399456b9e411825e298cff5940efea.tar.gz
itools-a165bf3c9b399456b9e411825e298cff5940efea.tar.bz2
itools-a165bf3c9b399456b9e411825e298cff5940efea.zip
fix urls with double ?
-rw-r--r--it_html.class1
-rwxr-xr-xtests/it_html.t2
2 files changed, 2 insertions, 1 deletions
diff --git a/it_html.class b/it_html.class
index 9db8893..3537707 100644
--- a/it_html.class
+++ b/it_html.class
@@ -540,6 +540,7 @@ static function U(/* ... */)
if (!($u = @parse_url($base)))
list($u['path'], $u['query']) = explode("?", $base, 2);
+ $u['query'] = strtr($u['query'], array("?" => rawurlencode("?")));
$u['host'] = preg_match('/[^-_.0-9a-z]/i', $u['host']) && function_exists('idn_to_ascii') && ($idnahost = idn_to_ascii($GLOBALS['it_html']->p['charset'] == "iso-8859-1" ? utf8_encode($u['host']) : $u['host'])) ? $idnahost : $u['host']; # Punycode hostname to include into webpage
$u['host'] = preg_replace_callback('/[^-_.0-9a-z\x80-\xff]/i', function($m) { return rawurlencode($m[0]); }, $u['host']); # Encode garbage chars in host
diff --git a/tests/it_html.t b/tests/it_html.t
index 22c8459..2dc7be5 100755
--- a/tests/it_html.t
+++ b/tests/it_html.t
@@ -197,7 +197,7 @@ is(
is(
U('/test.html?foo=bar?qux=gna', array('?q' => '?r')),
- '/test.html?foo=bar?qux=gna&%3Fq=%3Fr',
+ '/test.html?foo=bar%3Fqux=gna&%3Fq=%3Fr',
'U() quoting of ? in args but not base'
);
is(