note 84197 added to function.urldecode
| From: | ignacio dot javier dot igjav at gmail dot com | Date: | Wed, 02 Jul 2008 23:04:12 +0000 |
| Subject: | note 84197 added to function.urldecode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141090@lists.php.net to get a copy of this message | ||
/*
Original source has lost, seems due to a utf8-ascii-utf8 translation, 2 relevant characters in 2
lines of the function, character à in lines 8 and 21. This is the correct version:
*/
function crossUrlDecode($source) {
$decodedStr = '';
$pos = 0;
$len = strlen($source);
while ($pos < $len) {
$charAt = substr ($source, $pos, 1);
if ($charAt == 'Ã') {
$char2 = substr($source, $pos, 2);
$decodedStr .= htmlentities(utf8_decode($char2),ENT_QUOTES,'ISO-8859-1');
$pos += 2;
}
elseif(ord($charAt) > 127) {
$decodedStr .= "&#".ord($charAt).";";
$pos++;
}
elseif($charAt == '%') {
$pos++;
$hex2 = substr($source, $pos, 2);
$dechex = chr(hexdec($hex2));
if($dechex == 'Ã') {
$pos += 2;
if(substr($source, $pos, 1) == '%') {
$pos++;
$char2a = chr(hexdec(substr($source, $pos, 2)));
$decodedStr .= htmlentities(utf8_decode($dechex .
$char2a),ENT_QUOTES,'ISO-8859-1');
}
else {
$decodedStr .= htmlentities(utf8_decode($dechex));
}
}
else {
$decodedStr .= $dechex;
}
$pos += 2;
}
else {
$decodedStr .= $charAt;
$pos++;
}
}
return $decodedStr;
}
----
Server IP: 64.71.164.2
Probable Submitter: 62.83.52.120
----
Manual Page -- http://www.php.net/manual/en/function.urldecode.php
Edit -- https://master.php.net/note/edit/84197
Del: integrated -- https://master.php.net/note/delete/84197/integrated
Del: useless -- https://master.php.net/note/delete/84197/useless
Del: bad code -- https://master.php.net/note/delete/84197/bad+code
Del: spam -- https://master.php.net/note/delete/84197/spam
Del: non-english -- https://master.php.net/note/delete/84197/non-english
Del: in docs -- https://master.php.net/note/delete/84197/in+docs
Del: other reasons-- https://master.php.net/note/delete/84197
Reject -- https://master.php.net/note/reject/84197
Search -- https://master.php.net/manage/user-notes.php