1. #1
    Ext User keithpitt's Avatar
    Join Date
    Apr 2007
    Location
    Adelaide, Australia
    Posts
    58
    Vote Rating
    0
    keithpitt is on a distinguished road

      0  

    Default [2.0.1] Ext.urlEncode woes.

    [2.0.1] Ext.urlEncode woes.


    Gday all,

    I came across a bug in the url encode function today, and I just thought I'd share it with you and a solution I found. In my form, I have a multiselect, and an hidden input both with the same name. i.e.

    <input type="hidden" name="foo" value="hidden" />
    <select name="foo">
    <option value="1">one</option>
    <option value="2">two</option>
    </select>

    Now, I used the prototype Form.serialze method to convert all the values in the form to a object, it gave me the following:

    obj = { foo: ["hidden", [ "1", "2" ]] }

    which is correct.

    Now what happened was, that got passed to Ext.urlEncode (by virtue of Ext.Ajax.request), and it converted it to the following:

    PHP Code:
    foo=hidden&foo=1,
    which is not so correct. To be correct, it should have been:

    PHP Code:
    foo=hidden&foo=1&foo=
    So, I jumped into the source code, and added some extra logic to fix this issue. In the urlEncode function, in the if that parses an array, I modified it to look like this:

    PHP Code:
    }else if(ov instanceof Array){
       if (
    ov.length) {
          
          
    // Flatten the array before using it.      
          
    var ovv = [];
          for(var 
    0len ov.lengthleni++)
             
    ovv ovv.concat(ov[i]);
          
          for(var 
    0len ovv.lengthleni++) {
             
    buf.push(k"="encodeURIComponent(ovv[i] === undefined '' ovv[i]), "&");
          }
       
       } else {
          
    buf.push(k"=&");
       }

    I hope this helps anyone

    Keith

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    2
    Vote Rating
    0
    brian.moeskau is an unknown quantity at this point

      0  

    Default


    Thanks Keith, we'll take a look at your patch.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar