[drupal-devel] urlencode

Karoly Negyesi karoly at negyesi.net
Tue Mar 22 05:59:02 UTC 2005


Hi!

The problem is that if you have for eg. a slash in the string it will cause 
problems, it needs to be urlencoded. But PHP urlencode does not escape the 
slash. 

So I propose that we change urlencode to drupal_urlencode, as follows:

function _drupal_urlencode($matches) {
  return '%'. dechex(ord($matches[0]));
}
function drupal_urlencode($string) {
return preg_replace_callback('/[^[:alpha:]]/', '_drupal_urlencode', $title);
}

Of course, I'd love to see a simpler approach to the problem, but that's 
what came to my regexp obsessed mind...

Regards

NK



More information about the drupal-devel mailing list