Hybrid View

    You found a bug! We've classified it as TOUCH-2629 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Posts
    862
    Vote Rating
    21
    jep will become famous soon enough jep will become famous soon enough

      0  

    Default Ext.urlDecode does not decode "+" (plus sign) as space

    Ext.urlDecode does not decode "+" (plus sign) as space


    Sencha Touch version tested:
    • 1.1.1

    Platform tested against:
    • iOS 5
    • Chrome 17 on XP

    Description:
    • Ext.urlDecode does not decode the + (plus sign) as a space.

      Let me back up and say I was a little torn on whether to file this as a bug or a feature request. If the purpose of urlDecode is to simply decode URLs (or more specifically, URIs), then there really is no "bug" because the URI standards don't say much on topic.

      However, if the purpose of urlDecode is to decode query parameters that are originally passed in via a URL, I'd consider this very lacking behavior. While it is also completely harmless to encode a space as %20, both the html4 and html5 specs for application/x-www-form-urlencoded data say that the "right" way to do it is to encode space as "+".

      Since that's the only defined way of building query params, that's the way a whole lot of applications are going to pass those params. Hence when interacting with other applications, you might get your parameters with +s instead of %20s.

      Now, if you're only EVER using Ext.urlDecode() to decode something that Ext.urlEncode() encoding (meaning you're not interacting with anything), you're completely safe.

      There's a pretty good discussion of all the issues here:
      http://unixpapa.com/js/querystring.html

      He basically came to the same conclusions I did in the sections "2. Query String Standards (or the Lack Thereof)" and "3.1. The Built-In Functions Are Not Meant for Query Strings". He also suggested the same workaround I have. Basically, you just replace the +s with spaces before calling the underlying decodeURIComponent() function.

    Test Case:

    Code:
    console.log(Ext.urlDecode("param=one+two+three").param)
    Steps to reproduce the problem:
    • Run the above code on the console

    The result that was expected:
    • one two three

    The result that occurs instead:
    • one+two+three

    Possible fix:
    Code:
      urlDecode : function(string, overwrite) {
          if (Ext.isEmpty(string)) {
              return {};
          }
    
          var obj = {},
              pairs = string.replace(/\+/g, ' ').split('&'),
              d = decodeURIComponent,
              name,
              value;
    
          Ext.each(pairs, function(pair) {
              pair = pair.split('=');
              name = d(pair[0]);
              value = d(pair[1]);
              obj[name] = overwrite || !obj[name] ? value : [].concat(obj[name]).concat(value);
          });
    
          return obj;
      }

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,754
    Vote Rating
    827
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thank you for the report.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi