summaryrefslogtreecommitdiff
path: root/it_html.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_html.class')
-rw-r--r--it_html.class6
1 files changed, 3 insertions, 3 deletions
diff --git a/it_html.class b/it_html.class
index 68ca04a..b867c0b 100644
--- a/it_html.class
+++ b/it_html.class
@@ -501,11 +501,11 @@ function U(/* ... */)
list($u['path'], $u['query']) = explode("?", $base, 2);
$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('/[^-_.0-9a-z\x80-\xff]/ie', "rawurlencode('\$0')", $u['host']); # Encode garbage chars in host
+ $u['host'] = preg_replace_callback('/[^-_.0-9a-z\x80-\xff]/i', function($m) { return rawurlencode($m[0]); }, $u['host']); # Encode garbage chars in host
# handle scheme, user (urlencoded), password, host
$hostpart =
- ($u['user'] ? preg_replace('|[^-a-z0-9_.+!*(),:?@&=/~$%#]|ie', 'urlencode(stripslashes("$0"))', $u['user'] . ($u['pass'] ? ":" . $u['pass'] : "") . "@") : "") .
+ ($u['user'] ? preg_replace('|[^-a-z0-9_.+!*(),:?@&=/~$%#]|i', function($m) { return urlencode($m[0]); }, $u['user'] . ($u['pass'] ? ":" . $u['pass'] : "") . "@") : "") .
($u['host'] ? $u['host'] : "") .
($u['port'] ? ":" . intval($u['port']) : "");
@@ -519,7 +519,7 @@ function U(/* ... */)
$parts[$i] = (preg_match('/[0-9a-f][0-9a-f]/i', $parts[$i]) ? "%" : "%25") . $parts[$i];
$path = join("", $parts);
- $path = preg_replace('|[^-a-z0-9_.+!*(),:?@&=/~$%#]|ie', 'urlencode(stripslashes("$0"))', $path); # Single quotes are escaped with slash by preg_replace, remove it for urlencode
+ $path = preg_replace_callback('|[^-a-z0-9_.+!*(),:?@&=/~$%#]|i', function($m) { return urlencode($m[0]); }, $path);
$path = preg_replace('|^([a-z0-9_]+:)?//[^/]*$|', '$0/', $path); # Add slash if absolute url without a path, e.g. http://gna.ch
$queryparams = it_url::params($params);
$separator = strpos($path, "?") === false ? "?" : "&";