note 104650 rejected from function.urldecode by danbrown

From: Date: Tue, 28 Jun 2011 19:21:09 +0000
Subject: note 104650 rejected from function.urldecode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181016@lists.php.net to get a copy of this message
Note Submitter: jake at infinitylimited dot net ---- Having a problem with reserved HTML words in the URL being decoded. The code in question is below: <?php $baseURL = "http://host/result?thing=foo&quotes=BAR"; $encodedURL = urlencode($baseURL); echo "Encoded URL: $encodedURL<br>\n"; echo "URL " . urldecode($encodedURL) ."<br>\n"; ?> Results in: Encoded URL: http%3A%2F%2Fhost%2Fresult URL = host/result?thing=foo"es=BAR (I removed the http:// bit to avoid confusiong with auto-formatting) It appears that the urldecode() function is decoding %26quotes to &quotes first, then decoding that to "es I'm not sure what I"m going to do about it: perhaps escape quotes before encoding?

« previous php.notes (#181016) next »