note 99973 deleted from function.parse-url by cmb
| From: | cmb@php.net | Date: | Sun, 06 Oct 2019 08:19:01 +0000 |
| Subject: | note 99973 deleted from function.parse-url by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212509@lists.php.net to get a copy of this message | ||
Note Submitter: martin at planio dot com
----
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;
}
?>