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;
        }
    }
    
});