#12 Keyed arrays get passed incorrectly through POST

open
nobody
None
5
2014-08-17
2005-02-23
No

At the moment, post variables which are referred to by
key (for example you may have expDate[m] and expDate[y]
in a credit card form) get reindexed before being
passed, so they come through as expDate[0] and expDate[1].

Here is an example patch:

===================================================================
RCS file:
/usr/cvsroot/php-packages/sourceforge/snoopy/Snoopy.class.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -c -p -r1.3 -r1.4
*** php-packages/sourceforge/snoopy/Snoopy.class.php
2005/02/23 02:06:23 1.3
--- php-packages/sourceforge/snoopy/Snoopy.class.php
2005/02/23 02:07:23 1.4
*************** class Snoopy
*** 1182,1188 ****
while(list($key,$val) = each($formvars)) {
if (is_array($val) || is_object($val)) {
while (list($cur_key, $cur_val) = each($val)) {
! $postdata .=
urlencode($key)."[]=".urlencode($cur_val)."&";
}
} else
$postdata .=
urlencode($key)."=".urlencode($val)."&";
--- 1182,1188 ----
while(list($key,$val) = each($formvars)) {
if (is_array($val) || is_object($val)) {
while (list($cur_key, $cur_val) = each($val)) {
! $postdata .=
urlencode($key)."[$cur_key]=".urlencode($cur_val)."&";
}
} else
$postdata .=
urlencode($key)."=".urlencode($val)."&";

Discussion

  • David Rainsford

    David Rainsford - 2005-02-23

    Logged In: YES
    user_id=1039912

    sorry - that doesn't actually look very clear.

    Line 1182:
    $postdata .= urlencode($key)."[]=".urlencode($cur_val)."&";

    should be changed to :
    $postdata .=
    urlencode($key)."[$cur_key]=".urlencode($cur_val)."&";

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks