#158687 by drumm: fix URI encoding of some special chars

6.x
Gábor Hojtsy 2007-07-13 20:07:15 +00:00
parent 51b789c0d3
commit 3cccee7f4a
2 changed files with 9 additions and 7 deletions

View File

@ -2149,17 +2149,19 @@ function drupal_json($var = NULL) {
* Notes:
* - For esthetic reasons, we do not escape slashes. This also avoids a 'feature'
* in Apache where it 404s on any path containing '%2F'.
* - mod_rewrite's unescapes %-encoded ampersands and hashes when clean URLs
* are used, which are interpreted as delimiters by PHP. These characters are
* double escaped so PHP will still see the encoded version.
* - mod_rewrite unescapes %-encoded ampersands, hashes, and slashes when clean
* URLs are used, which are interpreted as delimiters by PHP. These
* characters are double escaped so PHP will still see the encoded version.
* - With clean URLs, Apache changes '//' to '/', so every second slash is
* double escaped.
*
* @param $text
* String to encode
*/
function drupal_urlencode($text) {
if (variable_get('clean_url', '0')) {
return str_replace(array('%2F', '%26', '%23'),
array('/', '%2526', '%2523'),
return str_replace(array('%2F', '%26', '%23', '//'),
array('/', '%2526', '%2523', '/%252F'),
urlencode($text));
}
else {

View File

@ -369,8 +369,8 @@ Drupal.unfreezeHeight = function () {
*/
Drupal.encodeURIComponent = function (item, uri) {
uri = uri || location.href;
item = encodeURIComponent(item).replace('%2F', '/');
return uri.indexOf('?q=') ? item : item.replace('%26', '%2526').replace('%23', '%2523');
item = encodeURIComponent(item).replace(/%2F/g, '/');
return (uri.indexOf('?q=') != -1) ? item : item.replace(/%26/g, '%2526').replace(/%23/g, '%2523').replace(/\/\//g, '/%252F');
};
/**