[development] URL encoding
nitingupta.iitg at gmail.com
Thu Mar 11 13:23:01 UTC 2010
I am trying to convert a URL to its encoded equivalent. i.e.
http://example.com/path with spaces/ to
The problem I am facing is that rawurlencode or urlencode, encodes all the
characters and does not show mercy upon the reserved characters such as '?',
'#', '=' which makes the URL invalid after encoding. I understand that this
behavior of these functions is expected considering the fact that they are
to be used to encode data (such as query) that can be appended in an URL,
but it isn't helping the current situation.
I thought of the following procedure to achieve the above:
1. run rawurldecode on the input url, so that we do not accidentally
encode twice if whole or part of URL is already encoded.
2. then run rawurlencode, and then preg replace these reserved
Though it works, I am not sure if it is the correct way to handle this. Any
help through ideas or code will be highly appreciated as this will be useful
in Feeds Image Grabber <http://drupal.org/project/feeds_imagegrabber>
Links <http:///drupal.org/project/facebook_link> module.
Also, off the subject: shouldn't drupal_http_request() should take care of
Nitin Kumar Gupta
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the development