diff options
author | Christian Schneider | 2012-02-13 18:36:56 +0000 |
---|---|---|
committer | Christian Schneider | 2012-02-13 18:36:56 +0000 |
commit | 0a6849fc31206318d6a86a0ccfff48556934c486 (patch) | |
tree | 34cd9cd21dab005edca4f991fb0c985e473d1fc7 | |
parent | ca407bc3f8e3e6d5f042be787f96304687af097e (diff) | |
download | itools-0a6849fc31206318d6a86a0ccfff48556934c486.tar.gz itools-0a6849fc31206318d6a86a0ccfff48556934c486.tar.bz2 itools-0a6849fc31206318d6a86a0ccfff48556934c486.zip |
Replace more (to be removed) preg_replace /e modifier by preg_replace_callback
-rw-r--r-- | it_html.class | 6 |
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 ? "?" : "&"; |