summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it_html.class5
-rw-r--r--tests/U_tests.json4
2 files changed, 3 insertions, 6 deletions
diff --git a/it_html.class b/it_html.class
index 02f3f2a..c7105b7 100644
--- a/it_html.class
+++ b/it_html.class
@@ -556,10 +556,7 @@ static function U(/* ... */)
$schemepart = $hostpart ? ($u['scheme'] ? $u['scheme'] . ":" : "") . "//$hostpart" : ($u['scheme'] == "mailto" ? $u['scheme'] . ":" : "");
# hack: encode % if not followed by two hex digits
- $parts = preg_split('/%([^%]{0,2})/', $u['path'], -1, PREG_SPLIT_DELIM_CAPTURE);
- for ($i = 1; $i < count($parts); $i+=2)
- $parts[$i] = (preg_match('/[0-9a-f][0-9a-f]/i', $parts[$i]) ? "%" : "%25") . $parts[$i];
- $path = join("", $parts);
+ $path = preg_replace('/%(?![0-9a-f]{2})/i', '%25', $u['path']);
# if params replace url parameters that are present in base, replace them but keep their order
foreach ($u['params'] as $key => $dummy)
diff --git a/tests/U_tests.json b/tests/U_tests.json
index bf8d129..a8b5688 100644
--- a/tests/U_tests.json
+++ b/tests/U_tests.json
@@ -37,8 +37,8 @@
},
{
- "args": ["%% %1%x %1x%x1%xx%11%ff%FF"],
- "exp": "%25%25%20%251%25x%20%251x%25x1%25xx%11%ff%FF",
+ "args": ["%% %1%x %1x%x1%xx%11%ff%FF%0f%0F %"],
+ "exp": "%25%25%20%251%25x%20%251x%25x1%25xx%11%ff%FF%0f%0F%20%25",
"name": "U() quoting of % if not followed by 2 hex digits"
},