1. #1
    Ext JS Premium Member
    Join Date
    Feb 2008
    Location
    France, Paris
    Posts
    38
    Vote Rating
    0
    aurelien is on a distinguished road

      0  

    Default [2.x] Ext.state.Provider.decodeValue() fails with line feed in state value

    [2.x] Ext.state.Provider.decodeValue() fails with line feed in state value


    Hello all -

    Because I've been working on a persistent TextArea based on ExtJS state management, I found the following bug (I think it's a bug...).

    When the value contains line feeds the decodeValue return null because of the regular expression (because of the TextArea I've line feed %0A):

    Code:
    decodeValue : function(cookie){
            var re = /^(a|n|d|b|s|o)\:(.*)$/;
            var matches = re.exec(unescape(cookie));
            if(!matches || !matches[1]) return; // non state cookie
    The following regular expression corrects the problem:

    Code:
    var re = /^(a|n|d|b|s|o)\:([\s\S]*)$/
    And the ready to use file Ext.state.Provider.js to include to override this behaviour:

    Code:
    /** aurelien - 28/08/2008
     * @link: http://extjs.com/forum/showthread.php?t=45428
    */
    Ext.state.Provider.override({
        /**
         * Decodes a string previously encoded with encodeValue.
         * Corrects a bug when the state value contains a line feed (%0A).
         * @param {String} value The value to decode
         * @return {Mixed} The decoded value
         */
    	decodeValue : function(cookie){
            var re = /^(a|n|d|b|s|o)\:([\s\S]*)$/
            var matches = re.exec(unescape(cookie));
            
            if(!matches || !matches[1]) return; // non state cookie
    
            var type = matches[1];
            var v = matches[2];
    
            switch(type){
                case "n":
                    return parseFloat(v);
                case "d":
                    return new Date(Date.parse(v));
                case "b":
                    return (v == "1");
                case "a":
                    var all = [];
                    var values = v.split("^");
                    for(var i = 0, len = values.length; i < len; i++){
                        all.push(this.decodeValue(values[i]));
                    }
                    return all;
               case "o":
                    var all = {};
                    var values = v.split("^");
                    for(var i = 0, len = values.length; i < len; i++){
                        var kv = values[i].split("=");
                        all[kv[0]] = this.decodeValue(kv[1]);
                    }
                    return all;
               default:
                    return v;
            }
        }
        
    });

  2. #2
    Ext Premium Member yyogev's Avatar
    Join Date
    Jun 2009
    Location
    Shoham, Israel
    Posts
    196
    Vote Rating
    6
    yyogev is on a distinguished road

      0  

    Exclamation Bug remains in 3.3

    Bug remains in 3.3


    I'll try to get it in the premium help forum.
    Yaron Yogev

    IT Software Developer

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