note 99973 added to function.parse-url
| From: | martin at planio dot com | Date: | Fri, 17 Sep 2010 14:02:51 +0000 |
| Subject: | note 99973 added to function.parse-url | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172675@lists.php.net to get a copy of this message | ||
For those of you sending URLs in HTML emails with a redirect address in the query string, note that
Hotmail unescapes / and : characters in the query string. So that breaks the parse_url() function
call. Take this as an example:
href="http://example.com/redirect?url=http%3A%2F%2Fplanio.com"
Hotmail will transform it to this:
href="http://example.com/redirect?url=http://planio.com"
The solution is to be preventive before the call to parse_url():
<?php
$q_index = strpos($uri, '?');
if ($q_index !== FALSE &&
(strpos($uri, ':', $q_index) !== FALSE || strpos($uri, '/', $q_index) !==
FALSE)) {
$begin = substr($uri, 0, $q_index);
$end = substr($uri, $q_index, strlen($uri)-$q_index);
$end = str_replace('/', '%2F', $end);
$end = str_replace(':', '%3A', $end);
$uri = $begin.$end;
}
?>
----
Server IP: 216.235.13.26
Probable Submitter: 69.70.138.86
----
Manual Page -- http://www.php.net/manual/en/function.parse-url.php
Edit -- https://master.php.net/note/edit/99973
Del: integrated -- https://master.php.net/note/delete/99973/integrated
Del: useless -- https://master.php.net/note/delete/99973/useless
Del: bad code -- https://master.php.net/note/delete/99973/bad+code
Del: spam -- https://master.php.net/note/delete/99973/spam
Del: non-english -- https://master.php.net/note/delete/99973/non-english
Del: in docs -- https://master.php.net/note/delete/99973/in+docs
Del: other reasons-- https://master.php.net/note/delete/99973
Reject -- https://master.php.net/note/reject/99973
Search -- https://master.php.net/manage/user-notes.php