#20098 [NEW]: POSTed variables are urldecoded twice
| From: | Marcus dot Dietz at unibw-muenchen dot de | Date: | Fri, 25 Oct 2002 20:09:11 +0000 |
| Subject: | #20098 [NEW]: POSTed variables are urldecoded twice | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-23344@lists.php.net to get a copy of this message | ||
From: Marcus.Dietz@unibw-muenchen.de
Operating system: FreeBSD 4.7-RELEASE
PHP version: 4.2.3
PHP Bug Type: Scripting Engine problem
Bug description: POSTed variables are urldecoded twice
If you type a '+' in a field it get's converted to
'%2B' before sent to the server. php urldecodes it
twice: '%2B' -> '+' -> ' '.
The problem is in the file:
ext/mbstring/mbstring.c: lines 1033-1045:
val = strchr(var, '=');
val_list[n] = var;
len_list[n] = php_url_decode(var, strlen(var));
n++;
if (val) { /* have a value */
*val++ = '\0';
val_list[n] = val;
len_list[n] = php_url_decode(val, strlen(val));
} else {
val_list[n] = "";
len_list[n] = 0;
}
A possible bugfix is:
==== BEGIN diff ===========================================
*** ext/mbstring/mbstring.c.ORIG Thu Aug 1 07:47:56 2002
--- ext/mbstring/mbstring.c Fri Oct 25 21:36:40 2002
***************
*** 1032,1041 ****
while (var) {
val = strchr(var, '=');
val_list[n] = var;
len_list[n] = php_url_decode(var, strlen(var));
n++;
if (val) { /* have a value */
- *val++ = '\0';
val_list[n] = val;
len_list[n] = php_url_decode(val, strlen(val));
} else {
--- 1032,1042 ----
while (var) {
val = strchr(var, '=');
val_list[n] = var;
+ if (val)
+ *val++ = '\0';
len_list[n] = php_url_decode(var, strlen(var));
n++;
if (val) { /* have a value */
val_list[n] = val;
len_list[n] = php_url_decode(val, strlen(val));
} else {
============================================================
--
Edit bug report at http://bugs.php.net/?id=20098&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20098&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=20098&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=20098&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20098&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=20098&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=20098&r=support
Expected behavior: http://bugs.php.net/fix.php?id=20098&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=20098&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=20098&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=20098&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20098&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=20098&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=20098&r=isapi