Fix encoding of urls (unicode safe)- introduces new Roo.encodeURIComponent
authorAlan Knowles <alan@akbkhome.com>
Thu, 17 Mar 2011 07:31:12 +0000 (07:31 +0000)
committerAlan Knowles <alan@akbkhome.com>
Tue, 6 Sep 2011 12:06:48 +0000 (20:06 +0800)
Roo.js
Roo/lib/Ajax.js
roojs-all.js
roojs-core-debug.js
roojs-core.js
roojs-debug.js

diff --git a/Roo.js b/Roo.js
index 7df38d2..98658cf 100644 (file)
--- a/Roo.js
+++ b/Roo.js
@@ -336,16 +336,16 @@ Roo.factory(conf, Roo.data);
             }
             var buf = [];
             for(var key in o){
-                var ov = o[key], k = encodeURIComponent(key);
+                var ov = o[key], k = Roo.encodeURIComponent(key);
                 var type = typeof ov;
                 if(type == 'undefined'){
                     buf.push(k, "=&");
                 }else if(type != "function" && type != "object"){
-                    buf.push(k, "=", encodeURIComponent(ov), "&");
+                    buf.push(k, "=", Roo.encodeURIComponent(ov), "&");
                 }else if(ov instanceof Array){
                     if (ov.length) {
                            for(var i = 0, len = ov.length; i < len; i++) {
-                               buf.push(k, "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
+                               buf.push(k, "=", Roo.encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
                            }
                        } else {
                            buf.push(k, "=&");
@@ -354,6 +354,60 @@ Roo.factory(conf, Roo.data);
             }
             buf.pop();
             return buf.join("");
+        },
+         /**
+         * Safe version of encodeURIComponent
+         * @param {String} data 
+         * @return {String} 
+         */
+        
+        encodeURIComponent : function (data)
+        {
+            try {
+                return encodeURIComponent(data);
+            } catch(e) {} // should be an uri encode error.
+            
+            if (data == '' || data == null){
+               return '';
+            }
+            // http://stackoverflow.com/questions/2596483/unicode-and-uri-encoding-decoding-and-escaping-in-javascript
+            function nibble_to_hex(nibble){
+                var chars = '0123456789ABCDEF';
+                return chars.charAt(nibble);
+            }
+            data = data.toString();
+            var buffer = '';
+            for(var i=0; i<data.length; i++){
+                var c = data.charCodeAt(i);
+                var bs = new Array();
+                if (c > 0x10000){
+                        // 4 bytes
+                    bs[0] = 0xF0 | ((c & 0x1C0000) >>> 18);
+                    bs[1] = 0x80 | ((c & 0x3F000) >>> 12);
+                    bs[2] = 0x80 | ((c & 0xFC0) >>> 6);
+                    bs[3] = 0x80 | (c & 0x3F);
+                }else if (c > 0x800){
+                         // 3 bytes
+                    bs[0] = 0xE0 | ((c & 0xF000) >>> 12);
+                    bs[1] = 0x80 | ((c & 0xFC0) >>> 6);
+                    bs[2] = 0x80 | (c & 0x3F);
+                }else if (c > 0x80){
+                       // 2 bytes
+                    bs[0] = 0xC0 | ((c & 0x7C0) >>> 6);
+                    bs[1] = 0x80 | (c & 0x3F);
+                }else{
+                        // 1 byte
+                    bs[0] = c;
+                }
+                for(var j=0; j<bs.length; j++){
+                    var b = bs[j];
+                    var hex = nibble_to_hex((b & 0xF0) >>> 4) 
+                            + nibble_to_hex(b &0x0F);
+                    buffer += '%'+hex;
+               }
+            }
+            return buffer;    
+             
         },
 
         /**
index c7a6f9f..4196565 100644 (file)
                             for (var j = 0; j < el.options.length; j++) {
                                 if (el.options[j].selected) {
                                     if (Roo.isIE) {
-                                        data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
+                                        data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
                                     }
                                     else {
-                                        data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
+                                        data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
                                     }
                                 }
                             }
@@ -61,7 +61,7 @@
                         case 'radio':
                         case 'checkbox':
                             if (el.checked) {
-                                data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
+                                data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(val) + '&';
                             }
                             break;
                         case 'file':
                             break;
                         case 'submit':
                             if(hasSubmit == false) {
-                                data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
+                                data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(val) + '&';
                                 hasSubmit = true;
                             }
                             break;
                         default:
-                            data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
+                            data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(val) + '&';
                             break;
                     }
                 }
index 42c65ad..4a6f1a8 100644 (file)
@@ -5,8 +5,9 @@ M=null;},id:function(el,M){M=M||"roo-gen";el=Roo.getDom(el);var id=M+(++A);retur
 sb.override=function(o){Roo.override(sb,o);};N.override=io;Roo.override(sb,M);return sb;};}(),override:function(M,N){if(N){var p=M.prototype;for(var O in N){p[O]=N[O];}}},namespace:function(){var a=arguments,o=null,i,j,d,rt;for(i=0;i<a.length;++i){d=a[i].split(".");rt=d[0];eval('if (typeof '+rt+' == "undefined"){'+rt+' = {};} o = '+rt+';');for(j=1;j<d.length;++j){o[d[j]]=o[d[j]]||{};o=o[d[j]];}}},factory:function(c,ns){if(!c.xtype||(!ns&&!c.xns)||(c.xns===false)){return c;}
 ns=c.xns?c.xns:ns;if(c.constructor==ns[c.xtype]){return c;}if(ns[c.xtype]){if(Roo.debug)Roo.log("Roo.Factory("+c.xtype+")");var M=new ns[c.xtype](c);M.xns=false;return M;}
 c.xns=false;return c;},log:function(s){if((typeof(console)=='undefined')||(typeof(console.log)=='undefined')){return;}
-console.log(s);},urlEncode:function(o){if(!o){return "";}var M=[];for(var N in o){var ov=o[N],k=encodeURIComponent(N);var O=typeof ov;if(O=='undefined'){M.push(k,"=&");}else if(O!="function"&&O!="object"){M.push(k,"=",encodeURIComponent(ov),"&");}else if(ov instanceof Array){if(ov.length){for(var i=0,P=ov.length;i<P;i++){M.push(k,"=",encodeURIComponent(ov[i]===undefined?'':ov[i]),"&");}}else {M.push(k,"=&");}}}
-M.pop();return M.join("");},urlDecode:function(M,N){if(!M||!M.length){return {};}var O={};var P=M.split('&');var Q,R,S;for(var i=0,T=P.length;i<T;i++){Q=P[i].split('=');R=decodeURIComponent(Q[0]);S=decodeURIComponent(Q[1]);if(N!==true){if(typeof O[R]=="undefined"){O[R]=S;}else if(typeof O[R]=="string"){O[R]=[O[R]];O[R].push(S);}else {O[R].push(S);}}else {O[R]=S;}}return O;},each:function(M,fn,N){if(typeof M.length=="undefined"||typeof M=="string"){M=[M];}for(var i=0,O=M.length;i<O;i++){if(fn.call(N||M[i],M[i],i,M)===false){return i;};}},combine:function(){var as=arguments,l=as.length,r=[];for(var i=0;i<l;i++){var a=as[i];if(a instanceof Array){r=r.concat(a);}else if(a.length!==undefined&&!a.substr){r=r.concat(Array.prototype.slice.call(a,0));}else {r.push(a);}}return r;},escapeRe:function(s){return s.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");},callback:function(cb,M,N,O){if(typeof cb=="function"){if(O){cb.defer(O,M,N||[]);}else {cb.apply(M,N||[]);}}},getDom:function(el){if(!el){return null;}return el.dom?el.dom:(typeof el=='string'?document.getElementById(el):el);},getCmp:function(id){return Roo.ComponentMgr.get(id);},num:function(v,M){if(typeof v!='number'){return M;}return v;},destroy:function(){for(var i=0,a=arguments,M=a.length;i<M;i++){var as=a[i];if(as){if(as.dom){as.removeAllListeners();as.remove();continue;}if(typeof as.purgeListeners=='function'){as.purgeListeners();}if(typeof as.destroy=='function'){as.destroy();}}}},type:function(o){if(o===undefined||o===null){return false;}if(o.htmlElement){return 'element';}var t=typeof o;if(t=='object'&&o.nodeName){switch(o.nodeType){case 1:return 'element';case 3:return (/\S/).test(o.nodeValue)?'textnode':'whitespace';}}if(t=='object'||t=='function'){switch(o.constructor){case Array:return 'array';case RegExp:return 'regexp';}if(typeof o.length=='number'&&typeof o.item=='function'){return 'nodelist';}}return t;},isEmpty:function(v,M){return v===null||v===undefined||(!M?v==='':false);},isOpera:C,isSafari:D,isIE:E,isIE7:F,isGecko:G,isBorderBox:H,isWindows:I,isLinux:K,isMac:J,useShims:((E&&!F)||(G&&J)),selectNode:function(M,N){var O=Roo.DomQuery.selectNode(M,N);return O?Roo.get(O):new Roo.Element(false);}});})();Roo.namespace("Roo","Roo.util","Roo.grid","Roo.dd","Roo.tree","Roo.data","Roo.form","Roo.menu","Roo.state","Roo.lib","Roo.layout","Roo.app","Roo.ux");
+console.log(s);},urlEncode:function(o){if(!o){return "";}var M=[];for(var N in o){var ov=o[N],k=Roo.encodeURIComponent(N);var O=typeof ov;if(O=='undefined'){M.push(k,"=&");}else if(O!="function"&&O!="object"){M.push(k,"=",Roo.encodeURIComponent(ov),"&");}else if(ov instanceof Array){if(ov.length){for(var i=0,P=ov.length;i<P;i++){M.push(k,"=",Roo.encodeURIComponent(ov[i]===undefined?'':ov[i]),"&");}}else {M.push(k,"=&");}}}
+M.pop();return M.join("");},encodeURIComponent:function(M){try{return encodeURIComponent(M);}catch(e){}if(M==''||M==null){return '';}function nibble_to_hex(P){var Q='0123456789ABCDEF';return Q.charAt(P);}
+M=M.toString();var N='';for(var i=0;i<M.length;i++){var c=M.charCodeAt(i);var bs=new Array();if(c>0x10000){bs[0]=0xF0|((c&0x1C0000)>>>18);bs[1]=0x80|((c&0x3F000)>>>12);bs[2]=0x80|((c&0xFC0)>>>6);bs[3]=0x80|(c&0x3F);}else if(c>0x800){bs[0]=0xE0|((c&0xF000)>>>12);bs[1]=0x80|((c&0xFC0)>>>6);bs[2]=0x80|(c&0x3F);}else if(c>0x80){bs[0]=0xC0|((c&0x7C0)>>>6);bs[1]=0x80|(c&0x3F);}else {bs[0]=c;}for(var j=0;j<bs.length;j++){var b=bs[j];var O=nibble_to_hex((b&0xF0)>>>4)+nibble_to_hex(b&0x0F);N+='%'+O;}}return N;},urlDecode:function(M,N){if(!M||!M.length){return {};}var O={};var P=M.split('&');var Q,R,S;for(var i=0,T=P.length;i<T;i++){Q=P[i].split('=');R=decodeURIComponent(Q[0]);S=decodeURIComponent(Q[1]);if(N!==true){if(typeof O[R]=="undefined"){O[R]=S;}else if(typeof O[R]=="string"){O[R]=[O[R]];O[R].push(S);}else {O[R].push(S);}}else {O[R]=S;}}return O;},each:function(M,fn,N){if(typeof M.length=="undefined"||typeof M=="string"){M=[M];}for(var i=0,O=M.length;i<O;i++){if(fn.call(N||M[i],M[i],i,M)===false){return i;};}},combine:function(){var as=arguments,l=as.length,r=[];for(var i=0;i<l;i++){var a=as[i];if(a instanceof Array){r=r.concat(a);}else if(a.length!==undefined&&!a.substr){r=r.concat(Array.prototype.slice.call(a,0));}else {r.push(a);}}return r;},escapeRe:function(s){return s.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");},callback:function(cb,M,N,O){if(typeof cb=="function"){if(O){cb.defer(O,M,N||[]);}else {cb.apply(M,N||[]);}}},getDom:function(el){if(!el){return null;}return el.dom?el.dom:(typeof el=='string'?document.getElementById(el):el);},getCmp:function(id){return Roo.ComponentMgr.get(id);},num:function(v,M){if(typeof v!='number'){return M;}return v;},destroy:function(){for(var i=0,a=arguments,M=a.length;i<M;i++){var as=a[i];if(as){if(as.dom){as.removeAllListeners();as.remove();continue;}if(typeof as.purgeListeners=='function'){as.purgeListeners();}if(typeof as.destroy=='function'){as.destroy();}}}},type:function(o){if(o===undefined||o===null){return false;}if(o.htmlElement){return 'element';}var t=typeof o;if(t=='object'&&o.nodeName){switch(o.nodeType){case 1:return 'element';case 3:return (/\S/).test(o.nodeValue)?'textnode':'whitespace';}}if(t=='object'||t=='function'){switch(o.constructor){case Array:return 'array';case RegExp:return 'regexp';}if(typeof o.length=='number'&&typeof o.item=='function'){return 'nodelist';}}return t;},isEmpty:function(v,M){return v===null||v===undefined||(!M?v==='':false);},isOpera:C,isSafari:D,isIE:E,isIE7:F,isGecko:G,isBorderBox:H,isWindows:I,isLinux:K,isMac:J,useShims:((E&&!F)||(G&&J)),selectNode:function(M,N){var O=Roo.DomQuery.selectNode(M,N);return O?Roo.get(O):new Roo.Element(false);}});})();Roo.namespace("Roo","Roo.util","Roo.grid","Roo.dd","Roo.tree","Roo.data","Roo.form","Roo.menu","Roo.state","Roo.lib","Roo.layout","Roo.app","Roo.ux");
 (function(){if(Roo.isIE){function fnCleanUp(){var p=Function.prototype;delete p.createSequence;delete p.defer;delete p.createDelegate;delete p.createCallback;delete p.createInterceptor;window.detachEvent("onunload",fnCleanUp);}
 window.attachEvent("onunload",fnCleanUp);}})();Roo.apply(Function.prototype,{createCallback:function(){var A=arguments;var B=this;return function(){return B.apply(window,A);};},createDelegate:function(A,B,C){var D=this;return function(){var E=B||arguments;if(C===true){E=Array.prototype.slice.call(arguments,0);E=E.concat(B);}else if(typeof C=="number"){E=Array.prototype.slice.call(arguments,0);var F=[C,0].concat(B);Array.prototype.splice.apply(E,F);}return D.apply(A||window,E);};},defer:function(A,B,C,D){var fn=this.createDelegate(B,C,D);if(A){return setTimeout(fn,A);}
 fn();return 0;},createSequence:function(A,B){if(typeof A!="function"){return this;}var C=this;return function(){var D=C.apply(this||window,arguments);A.apply(B||this||window,arguments);return D;};},createInterceptor:function(A,B){if(typeof A!="function"){return this;}var C=this;return function(){A.target=this;A.method=C;if(A.apply(B||this||window,arguments)===false){return;}return C.apply(this||window,arguments);};}});
@@ -36,7 +37,7 @@ j=j-1;}
 l=null;EU.clearCache();}
 EU.doRemove(window,"unload",EU._unload);},getScroll:function(){var dd=document.documentElement,db=document.body;if(dd&&(dd.scrollTop||dd.scrollLeft)){return [dd.scrollTop,dd.scrollLeft];}else if(db){return [db.scrollTop,db.scrollLeft];}else {return [0,0];}},doAdd:function(){if(window.addEventListener){return function(el,H,fn,I){el.addEventListener(H,fn,(I));};}else if(window.attachEvent){return function(el,H,fn,I){el.attachEvent("on"+H,fn);};}else {return function(){};}}(),doRemove:function(){if(window.removeEventListener){return function(el,H,fn,I){el.removeEventListener(H,fn,(I));};}else if(window.detachEvent){return function(el,H,fn){el.detachEvent("on"+H,fn);};}else {return function(){};}}()};}();(function(){var E=Roo.lib.Event;E.on=E.addListener;E.un=E.removeListener;if(document&&document.body){E._load();}else {E.doAdd(window,"load",E._load);}
 E.doAdd(window,"unload",E._unload);E._tryPreloadAttach();})();
-(function(){Roo.lib.Ajax={request:function(A,B,cb,C,D){if(D){var hs=D.headers;if(hs){for(var h in hs){if(hs.hasOwnProperty(h)){this.initHeader(h,hs[h],false);}}}if(D.xmlData){this.initHeader('Content-Type','text/xml',false);A='POST';C=D.xmlData;}}return this.asyncRequest(A,B,cb,C);},serializeForm:function(A){if(typeof A=='string'){A=(document.getElementById(A)||document.forms[A]);}var el,B,C,D,E='',F=false;for(var i=0;i<A.elements.length;i++){el=A.elements[i];D=A.elements[i].disabled;B=A.elements[i].name;C=A.elements[i].value;if(!D&&B){switch(el.type){case 'select-one':case 'select-multiple':for(var j=0;j<el.options.length;j++){if(el.options[j].selected){if(Roo.isIE){E+=encodeURIComponent(B)+'='+encodeURIComponent(el.options[j].attributes['value'].specified?el.options[j].value:el.options[j].text)+'&';}else {E+=encodeURIComponent(B)+'='+encodeURIComponent(el.options[j].hasAttribute('value')?el.options[j].value:el.options[j].text)+'&';}}}break;case 'radio':case 'checkbox':if(el.checked){E+=encodeURIComponent(B)+'='+encodeURIComponent(C)+'&';}break;case 'file':case undefined:case 'reset':case 'button':break;case 'submit':if(F==false){E+=encodeURIComponent(B)+'='+encodeURIComponent(C)+'&';F=true;}break;default:E+=encodeURIComponent(B)+'='+encodeURIComponent(C)+'&';break;}}}
+(function(){Roo.lib.Ajax={request:function(A,B,cb,C,D){if(D){var hs=D.headers;if(hs){for(var h in hs){if(hs.hasOwnProperty(h)){this.initHeader(h,hs[h],false);}}}if(D.xmlData){this.initHeader('Content-Type','text/xml',false);A='POST';C=D.xmlData;}}return this.asyncRequest(A,B,cb,C);},serializeForm:function(A){if(typeof A=='string'){A=(document.getElementById(A)||document.forms[A]);}var el,B,C,D,E='',F=false;for(var i=0;i<A.elements.length;i++){el=A.elements[i];D=A.elements[i].disabled;B=A.elements[i].name;C=A.elements[i].value;if(!D&&B){switch(el.type){case 'select-one':case 'select-multiple':for(var j=0;j<el.options.length;j++){if(el.options[j].selected){if(Roo.isIE){E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(el.options[j].attributes['value'].specified?el.options[j].value:el.options[j].text)+'&';}else {E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(el.options[j].hasAttribute('value')?el.options[j].value:el.options[j].text)+'&';}}}break;case 'radio':case 'checkbox':if(el.checked){E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(C)+'&';}break;case 'file':case undefined:case 'reset':case 'button':break;case 'submit':if(F==false){E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(C)+'&';F=true;}break;default:E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(C)+'&';break;}}}
 E=E.substr(0,E.length-1);return E;},headers:{},hasHeaders:false,useDefaultHeader:true,defaultPostHeader:'application/x-www-form-urlencoded',useDefaultXhrHeader:true,defaultXhrHeader:'XMLHttpRequest',hasDefaultHeaders:true,defaultHeaders:{},poll:{},timeout:{},pollInterval:50,transactionId:0,setProgId:function(id){this.activeX.unshift(id);},setDefaultPostHeader:function(b){this.useDefaultHeader=b;},setDefaultXhrHeader:function(b){this.useDefaultXhrHeader=b;},setPollingInterval:function(i){if(typeof i=='number'&&isFinite(i)){this.pollInterval=i;}},createXhrObject:function(A){var B,C;try{C=new XMLHttpRequest();B={conn:C,tId:A};}catch(e){for(var i=0;i<this.activeX.length;++i){try{http=new ActiveXObject(this.activeX[i]);obj={conn:http,tId:transactionId};break;}catch(e){}}}finally{return B;}},getConnectionObject:function(){var o;var A=this.transactionId;try{o=this.createXhrObject(A);if(o){this.transactionId++;}}catch(e){}finally{return o;}},asyncRequest:function(A,B,C,D){var o=this.getConnectionObject();if(!o){return null;}else {o.conn.open(A,B,true);if(this.useDefaultXhrHeader){if(!this.defaultHeaders['X-Requested-With']){this.initHeader('X-Requested-With',this.defaultXhrHeader,true);}}if(D&&this.useDefaultHeader){this.initHeader('Content-Type',this.defaultPostHeader);}if(this.hasDefaultHeaders||this.hasHeaders){this.setHeader(o);}
 this.handleReadyState(o,C);o.conn.send(D||null);return o;}},handleReadyState:function(o,A){var B=this;if(A&&A.timeout){this.timeout[o.tId]=window.setTimeout(function(){B.abort(o,A,true);},A.timeout);}
 this.poll[o.tId]=window.setInterval(function(){if(o.conn&&o.conn.readyState==4){window.clearInterval(B.poll[o.tId]);delete B.poll[o.tId];if(A&&A.timeout){window.clearTimeout(B.timeout[o.tId]);delete B.timeout[o.tId];}
index b091f14..940dc63 100644 (file)
@@ -336,16 +336,16 @@ Roo.factory(conf, Roo.data);
             }
             var buf = [];
             for(var key in o){
-                var ov = o[key], k = encodeURIComponent(key);
+                var ov = o[key], k = Roo.encodeURIComponent(key);
                 var type = typeof ov;
                 if(type == 'undefined'){
                     buf.push(k, "=&");
                 }else if(type != "function" && type != "object"){
-                    buf.push(k, "=", encodeURIComponent(ov), "&");
+                    buf.push(k, "=", Roo.encodeURIComponent(ov), "&");
                 }else if(ov instanceof Array){
                     if (ov.length) {
                            for(var i = 0, len = ov.length; i < len; i++) {
-                               buf.push(k, "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
+                               buf.push(k, "=", Roo.encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
                            }
                        } else {
                            buf.push(k, "=&");
@@ -354,6 +354,60 @@ Roo.factory(conf, Roo.data);
             }
             buf.pop();
             return buf.join("");
+        },
+         /**
+         * Safe version of encodeURIComponent
+         * @param {String} data 
+         * @return {String} 
+         */
+        
+        encodeURIComponent : function (data)
+        {
+            try {
+                return encodeURIComponent(data);
+            } catch(e) {} // should be an uri encode error.
+            
+            if (data == '' || data == null){
+               return '';
+            }
+            // http://stackoverflow.com/questions/2596483/unicode-and-uri-encoding-decoding-and-escaping-in-javascript
+            function nibble_to_hex(nibble){
+                var chars = '0123456789ABCDEF';
+                return chars.charAt(nibble);
+            }
+            data = data.toString();
+            var buffer = '';
+            for(var i=0; i<data.length; i++){
+                var c = data.charCodeAt(i);
+                var bs = new Array();
+                if (c > 0x10000){
+                        // 4 bytes
+                    bs[0] = 0xF0 | ((c & 0x1C0000) >>> 18);
+                    bs[1] = 0x80 | ((c & 0x3F000) >>> 12);
+                    bs[2] = 0x80 | ((c & 0xFC0) >>> 6);
+                    bs[3] = 0x80 | (c & 0x3F);
+                }else if (c > 0x800){
+                         // 3 bytes
+                    bs[0] = 0xE0 | ((c & 0xF000) >>> 12);
+                    bs[1] = 0x80 | ((c & 0xFC0) >>> 6);
+                    bs[2] = 0x80 | (c & 0x3F);
+                }else if (c > 0x80){
+                       // 2 bytes
+                    bs[0] = 0xC0 | ((c & 0x7C0) >>> 6);
+                    bs[1] = 0x80 | (c & 0x3F);
+                }else{
+                        // 1 byte
+                    bs[0] = c;
+                }
+                for(var j=0; j<bs.length; j++){
+                    var b = bs[j];
+                    var hex = nibble_to_hex((b & 0xF0) >>> 4) 
+                            + nibble_to_hex(b &0x0F);
+                    buffer += '%'+hex;
+               }
+            }
+            return buffer;    
+             
         },
 
         /**
@@ -2432,10 +2486,10 @@ Roo.lib.Event = function() {
                             for (var j = 0; j < el.options.length; j++) {
                                 if (el.options[j].selected) {
                                     if (Roo.isIE) {
-                                        data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
+                                        data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
                                     }
                                     else {
-                                        data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
+                                        data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
                                     }
                                 }
                             }
@@ -2443,7 +2497,7 @@ Roo.lib.Event = function() {
                         case 'radio':
                         case 'checkbox':
                             if (el.checked) {
-                                data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
+                                data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(val) + '&';
                             }
                             break;
                         case 'file':
@@ -2457,12 +2511,12 @@ Roo.lib.Event = function() {
                             break;
                         case 'submit':
                             if(hasSubmit == false) {
-                                data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
+                                data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(val) + '&';
                                 hasSubmit = true;
                             }
                             break;
                         default:
-                            data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
+                            data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(val) + '&';
                             break;
                     }
                 }
index e9859a0..0a3ad6e 100644 (file)
@@ -5,8 +5,9 @@ M=null;},id:function(el,M){M=M||"roo-gen";el=Roo.getDom(el);var id=M+(++A);retur
 sb.override=function(o){Roo.override(sb,o);};N.override=io;Roo.override(sb,M);return sb;};}(),override:function(M,N){if(N){var p=M.prototype;for(var O in N){p[O]=N[O];}}},namespace:function(){var a=arguments,o=null,i,j,d,rt;for(i=0;i<a.length;++i){d=a[i].split(".");rt=d[0];eval('if (typeof '+rt+' == "undefined"){'+rt+' = {};} o = '+rt+';');for(j=1;j<d.length;++j){o[d[j]]=o[d[j]]||{};o=o[d[j]];}}},factory:function(c,ns){if(!c.xtype||(!ns&&!c.xns)||(c.xns===false)){return c;}
 ns=c.xns?c.xns:ns;if(c.constructor==ns[c.xtype]){return c;}if(ns[c.xtype]){if(Roo.debug)Roo.log("Roo.Factory("+c.xtype+")");var M=new ns[c.xtype](c);M.xns=false;return M;}
 c.xns=false;return c;},log:function(s){if((typeof(console)=='undefined')||(typeof(console.log)=='undefined')){return;}
-console.log(s);},urlEncode:function(o){if(!o){return "";}var M=[];for(var N in o){var ov=o[N],k=encodeURIComponent(N);var O=typeof ov;if(O=='undefined'){M.push(k,"=&");}else if(O!="function"&&O!="object"){M.push(k,"=",encodeURIComponent(ov),"&");}else if(ov instanceof Array){if(ov.length){for(var i=0,P=ov.length;i<P;i++){M.push(k,"=",encodeURIComponent(ov[i]===undefined?'':ov[i]),"&");}}else {M.push(k,"=&");}}}
-M.pop();return M.join("");},urlDecode:function(M,N){if(!M||!M.length){return {};}var O={};var P=M.split('&');var Q,R,S;for(var i=0,T=P.length;i<T;i++){Q=P[i].split('=');R=decodeURIComponent(Q[0]);S=decodeURIComponent(Q[1]);if(N!==true){if(typeof O[R]=="undefined"){O[R]=S;}else if(typeof O[R]=="string"){O[R]=[O[R]];O[R].push(S);}else {O[R].push(S);}}else {O[R]=S;}}return O;},each:function(M,fn,N){if(typeof M.length=="undefined"||typeof M=="string"){M=[M];}for(var i=0,O=M.length;i<O;i++){if(fn.call(N||M[i],M[i],i,M)===false){return i;};}},combine:function(){var as=arguments,l=as.length,r=[];for(var i=0;i<l;i++){var a=as[i];if(a instanceof Array){r=r.concat(a);}else if(a.length!==undefined&&!a.substr){r=r.concat(Array.prototype.slice.call(a,0));}else {r.push(a);}}return r;},escapeRe:function(s){return s.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");},callback:function(cb,M,N,O){if(typeof cb=="function"){if(O){cb.defer(O,M,N||[]);}else {cb.apply(M,N||[]);}}},getDom:function(el){if(!el){return null;}return el.dom?el.dom:(typeof el=='string'?document.getElementById(el):el);},getCmp:function(id){return Roo.ComponentMgr.get(id);},num:function(v,M){if(typeof v!='number'){return M;}return v;},destroy:function(){for(var i=0,a=arguments,M=a.length;i<M;i++){var as=a[i];if(as){if(as.dom){as.removeAllListeners();as.remove();continue;}if(typeof as.purgeListeners=='function'){as.purgeListeners();}if(typeof as.destroy=='function'){as.destroy();}}}},type:function(o){if(o===undefined||o===null){return false;}if(o.htmlElement){return 'element';}var t=typeof o;if(t=='object'&&o.nodeName){switch(o.nodeType){case 1:return 'element';case 3:return (/\S/).test(o.nodeValue)?'textnode':'whitespace';}}if(t=='object'||t=='function'){switch(o.constructor){case Array:return 'array';case RegExp:return 'regexp';}if(typeof o.length=='number'&&typeof o.item=='function'){return 'nodelist';}}return t;},isEmpty:function(v,M){return v===null||v===undefined||(!M?v==='':false);},isOpera:C,isSafari:D,isIE:E,isIE7:F,isGecko:G,isBorderBox:H,isWindows:I,isLinux:K,isMac:J,useShims:((E&&!F)||(G&&J)),selectNode:function(M,N){var O=Roo.DomQuery.selectNode(M,N);return O?Roo.get(O):new Roo.Element(false);}});})();Roo.namespace("Roo","Roo.util","Roo.grid","Roo.dd","Roo.tree","Roo.data","Roo.form","Roo.menu","Roo.state","Roo.lib","Roo.layout","Roo.app","Roo.ux");
+console.log(s);},urlEncode:function(o){if(!o){return "";}var M=[];for(var N in o){var ov=o[N],k=Roo.encodeURIComponent(N);var O=typeof ov;if(O=='undefined'){M.push(k,"=&");}else if(O!="function"&&O!="object"){M.push(k,"=",Roo.encodeURIComponent(ov),"&");}else if(ov instanceof Array){if(ov.length){for(var i=0,P=ov.length;i<P;i++){M.push(k,"=",Roo.encodeURIComponent(ov[i]===undefined?'':ov[i]),"&");}}else {M.push(k,"=&");}}}
+M.pop();return M.join("");},encodeURIComponent:function(M){try{return encodeURIComponent(M);}catch(e){}if(M==''||M==null){return '';}function nibble_to_hex(P){var Q='0123456789ABCDEF';return Q.charAt(P);}
+M=M.toString();var N='';for(var i=0;i<M.length;i++){var c=M.charCodeAt(i);var bs=new Array();if(c>0x10000){bs[0]=0xF0|((c&0x1C0000)>>>18);bs[1]=0x80|((c&0x3F000)>>>12);bs[2]=0x80|((c&0xFC0)>>>6);bs[3]=0x80|(c&0x3F);}else if(c>0x800){bs[0]=0xE0|((c&0xF000)>>>12);bs[1]=0x80|((c&0xFC0)>>>6);bs[2]=0x80|(c&0x3F);}else if(c>0x80){bs[0]=0xC0|((c&0x7C0)>>>6);bs[1]=0x80|(c&0x3F);}else {bs[0]=c;}for(var j=0;j<bs.length;j++){var b=bs[j];var O=nibble_to_hex((b&0xF0)>>>4)+nibble_to_hex(b&0x0F);N+='%'+O;}}return N;},urlDecode:function(M,N){if(!M||!M.length){return {};}var O={};var P=M.split('&');var Q,R,S;for(var i=0,T=P.length;i<T;i++){Q=P[i].split('=');R=decodeURIComponent(Q[0]);S=decodeURIComponent(Q[1]);if(N!==true){if(typeof O[R]=="undefined"){O[R]=S;}else if(typeof O[R]=="string"){O[R]=[O[R]];O[R].push(S);}else {O[R].push(S);}}else {O[R]=S;}}return O;},each:function(M,fn,N){if(typeof M.length=="undefined"||typeof M=="string"){M=[M];}for(var i=0,O=M.length;i<O;i++){if(fn.call(N||M[i],M[i],i,M)===false){return i;};}},combine:function(){var as=arguments,l=as.length,r=[];for(var i=0;i<l;i++){var a=as[i];if(a instanceof Array){r=r.concat(a);}else if(a.length!==undefined&&!a.substr){r=r.concat(Array.prototype.slice.call(a,0));}else {r.push(a);}}return r;},escapeRe:function(s){return s.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");},callback:function(cb,M,N,O){if(typeof cb=="function"){if(O){cb.defer(O,M,N||[]);}else {cb.apply(M,N||[]);}}},getDom:function(el){if(!el){return null;}return el.dom?el.dom:(typeof el=='string'?document.getElementById(el):el);},getCmp:function(id){return Roo.ComponentMgr.get(id);},num:function(v,M){if(typeof v!='number'){return M;}return v;},destroy:function(){for(var i=0,a=arguments,M=a.length;i<M;i++){var as=a[i];if(as){if(as.dom){as.removeAllListeners();as.remove();continue;}if(typeof as.purgeListeners=='function'){as.purgeListeners();}if(typeof as.destroy=='function'){as.destroy();}}}},type:function(o){if(o===undefined||o===null){return false;}if(o.htmlElement){return 'element';}var t=typeof o;if(t=='object'&&o.nodeName){switch(o.nodeType){case 1:return 'element';case 3:return (/\S/).test(o.nodeValue)?'textnode':'whitespace';}}if(t=='object'||t=='function'){switch(o.constructor){case Array:return 'array';case RegExp:return 'regexp';}if(typeof o.length=='number'&&typeof o.item=='function'){return 'nodelist';}}return t;},isEmpty:function(v,M){return v===null||v===undefined||(!M?v==='':false);},isOpera:C,isSafari:D,isIE:E,isIE7:F,isGecko:G,isBorderBox:H,isWindows:I,isLinux:K,isMac:J,useShims:((E&&!F)||(G&&J)),selectNode:function(M,N){var O=Roo.DomQuery.selectNode(M,N);return O?Roo.get(O):new Roo.Element(false);}});})();Roo.namespace("Roo","Roo.util","Roo.grid","Roo.dd","Roo.tree","Roo.data","Roo.form","Roo.menu","Roo.state","Roo.lib","Roo.layout","Roo.app","Roo.ux");
 (function(){if(Roo.isIE){function fnCleanUp(){var p=Function.prototype;delete p.createSequence;delete p.defer;delete p.createDelegate;delete p.createCallback;delete p.createInterceptor;window.detachEvent("onunload",fnCleanUp);}
 window.attachEvent("onunload",fnCleanUp);}})();Roo.apply(Function.prototype,{createCallback:function(){var A=arguments;var B=this;return function(){return B.apply(window,A);};},createDelegate:function(A,B,C){var D=this;return function(){var E=B||arguments;if(C===true){E=Array.prototype.slice.call(arguments,0);E=E.concat(B);}else if(typeof C=="number"){E=Array.prototype.slice.call(arguments,0);var F=[C,0].concat(B);Array.prototype.splice.apply(E,F);}return D.apply(A||window,E);};},defer:function(A,B,C,D){var fn=this.createDelegate(B,C,D);if(A){return setTimeout(fn,A);}
 fn();return 0;},createSequence:function(A,B){if(typeof A!="function"){return this;}var C=this;return function(){var D=C.apply(this||window,arguments);A.apply(B||this||window,arguments);return D;};},createInterceptor:function(A,B){if(typeof A!="function"){return this;}var C=this;return function(){A.target=this;A.method=C;if(A.apply(B||this||window,arguments)===false){return;}return C.apply(this||window,arguments);};}});
@@ -36,7 +37,7 @@ j=j-1;}
 l=null;EU.clearCache();}
 EU.doRemove(window,"unload",EU._unload);},getScroll:function(){var dd=document.documentElement,db=document.body;if(dd&&(dd.scrollTop||dd.scrollLeft)){return [dd.scrollTop,dd.scrollLeft];}else if(db){return [db.scrollTop,db.scrollLeft];}else {return [0,0];}},doAdd:function(){if(window.addEventListener){return function(el,H,fn,I){el.addEventListener(H,fn,(I));};}else if(window.attachEvent){return function(el,H,fn,I){el.attachEvent("on"+H,fn);};}else {return function(){};}}(),doRemove:function(){if(window.removeEventListener){return function(el,H,fn,I){el.removeEventListener(H,fn,(I));};}else if(window.detachEvent){return function(el,H,fn){el.detachEvent("on"+H,fn);};}else {return function(){};}}()};}();(function(){var E=Roo.lib.Event;E.on=E.addListener;E.un=E.removeListener;if(document&&document.body){E._load();}else {E.doAdd(window,"load",E._load);}
 E.doAdd(window,"unload",E._unload);E._tryPreloadAttach();})();
-(function(){Roo.lib.Ajax={request:function(A,B,cb,C,D){if(D){var hs=D.headers;if(hs){for(var h in hs){if(hs.hasOwnProperty(h)){this.initHeader(h,hs[h],false);}}}if(D.xmlData){this.initHeader('Content-Type','text/xml',false);A='POST';C=D.xmlData;}}return this.asyncRequest(A,B,cb,C);},serializeForm:function(A){if(typeof A=='string'){A=(document.getElementById(A)||document.forms[A]);}var el,B,C,D,E='',F=false;for(var i=0;i<A.elements.length;i++){el=A.elements[i];D=A.elements[i].disabled;B=A.elements[i].name;C=A.elements[i].value;if(!D&&B){switch(el.type){case 'select-one':case 'select-multiple':for(var j=0;j<el.options.length;j++){if(el.options[j].selected){if(Roo.isIE){E+=encodeURIComponent(B)+'='+encodeURIComponent(el.options[j].attributes['value'].specified?el.options[j].value:el.options[j].text)+'&';}else {E+=encodeURIComponent(B)+'='+encodeURIComponent(el.options[j].hasAttribute('value')?el.options[j].value:el.options[j].text)+'&';}}}break;case 'radio':case 'checkbox':if(el.checked){E+=encodeURIComponent(B)+'='+encodeURIComponent(C)+'&';}break;case 'file':case undefined:case 'reset':case 'button':break;case 'submit':if(F==false){E+=encodeURIComponent(B)+'='+encodeURIComponent(C)+'&';F=true;}break;default:E+=encodeURIComponent(B)+'='+encodeURIComponent(C)+'&';break;}}}
+(function(){Roo.lib.Ajax={request:function(A,B,cb,C,D){if(D){var hs=D.headers;if(hs){for(var h in hs){if(hs.hasOwnProperty(h)){this.initHeader(h,hs[h],false);}}}if(D.xmlData){this.initHeader('Content-Type','text/xml',false);A='POST';C=D.xmlData;}}return this.asyncRequest(A,B,cb,C);},serializeForm:function(A){if(typeof A=='string'){A=(document.getElementById(A)||document.forms[A]);}var el,B,C,D,E='',F=false;for(var i=0;i<A.elements.length;i++){el=A.elements[i];D=A.elements[i].disabled;B=A.elements[i].name;C=A.elements[i].value;if(!D&&B){switch(el.type){case 'select-one':case 'select-multiple':for(var j=0;j<el.options.length;j++){if(el.options[j].selected){if(Roo.isIE){E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(el.options[j].attributes['value'].specified?el.options[j].value:el.options[j].text)+'&';}else {E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(el.options[j].hasAttribute('value')?el.options[j].value:el.options[j].text)+'&';}}}break;case 'radio':case 'checkbox':if(el.checked){E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(C)+'&';}break;case 'file':case undefined:case 'reset':case 'button':break;case 'submit':if(F==false){E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(C)+'&';F=true;}break;default:E+=Roo.encodeURIComponent(B)+'='+Roo.encodeURIComponent(C)+'&';break;}}}
 E=E.substr(0,E.length-1);return E;},headers:{},hasHeaders:false,useDefaultHeader:true,defaultPostHeader:'application/x-www-form-urlencoded',useDefaultXhrHeader:true,defaultXhrHeader:'XMLHttpRequest',hasDefaultHeaders:true,defaultHeaders:{},poll:{},timeout:{},pollInterval:50,transactionId:0,setProgId:function(id){this.activeX.unshift(id);},setDefaultPostHeader:function(b){this.useDefaultHeader=b;},setDefaultXhrHeader:function(b){this.useDefaultXhrHeader=b;},setPollingInterval:function(i){if(typeof i=='number'&&isFinite(i)){this.pollInterval=i;}},createXhrObject:function(A){var B,C;try{C=new XMLHttpRequest();B={conn:C,tId:A};}catch(e){for(var i=0;i<this.activeX.length;++i){try{http=new ActiveXObject(this.activeX[i]);obj={conn:http,tId:transactionId};break;}catch(e){}}}finally{return B;}},getConnectionObject:function(){var o;var A=this.transactionId;try{o=this.createXhrObject(A);if(o){this.transactionId++;}}catch(e){}finally{return o;}},asyncRequest:function(A,B,C,D){var o=this.getConnectionObject();if(!o){return null;}else {o.conn.open(A,B,true);if(this.useDefaultXhrHeader){if(!this.defaultHeaders['X-Requested-With']){this.initHeader('X-Requested-With',this.defaultXhrHeader,true);}}if(D&&this.useDefaultHeader){this.initHeader('Content-Type',this.defaultPostHeader);}if(this.hasDefaultHeaders||this.hasHeaders){this.setHeader(o);}
 this.handleReadyState(o,C);o.conn.send(D||null);return o;}},handleReadyState:function(o,A){var B=this;if(A&&A.timeout){this.timeout[o.tId]=window.setTimeout(function(){B.abort(o,A,true);},A.timeout);}
 this.poll[o.tId]=window.setInterval(function(){if(o.conn&&o.conn.readyState==4){window.clearInterval(B.poll[o.tId]);delete B.poll[o.tId];if(A&&A.timeout){window.clearTimeout(B.timeout[o.tId]);delete B.timeout[o.tId];}
index 0d6014c..51de3c2 100644 (file)
@@ -336,16 +336,16 @@ Roo.factory(conf, Roo.data);
             }
             var buf = [];
             for(var key in o){
-                var ov = o[key], k = encodeURIComponent(key);
+                var ov = o[key], k = Roo.encodeURIComponent(key);
                 var type = typeof ov;
                 if(type == 'undefined'){
                     buf.push(k, "=&");
                 }else if(type != "function" && type != "object"){
-                    buf.push(k, "=", encodeURIComponent(ov), "&");
+                    buf.push(k, "=", Roo.encodeURIComponent(ov), "&");
                 }else if(ov instanceof Array){
                     if (ov.length) {
                            for(var i = 0, len = ov.length; i < len; i++) {
-                               buf.push(k, "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
+                               buf.push(k, "=", Roo.encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
                            }
                        } else {
                            buf.push(k, "=&");
@@ -354,6 +354,60 @@ Roo.factory(conf, Roo.data);
             }
             buf.pop();
             return buf.join("");
+        },
+         /**
+         * Safe version of encodeURIComponent
+         * @param {String} data 
+         * @return {String} 
+         */
+        
+        encodeURIComponent : function (data)
+        {
+            try {
+                return encodeURIComponent(data);
+            } catch(e) {} // should be an uri encode error.
+            
+            if (data == '' || data == null){
+               return '';
+            }
+            // http://stackoverflow.com/questions/2596483/unicode-and-uri-encoding-decoding-and-escaping-in-javascript
+            function nibble_to_hex(nibble){
+                var chars = '0123456789ABCDEF';
+                return chars.charAt(nibble);
+            }
+            data = data.toString();
+            var buffer = '';
+            for(var i=0; i<data.length; i++){
+                var c = data.charCodeAt(i);
+                var bs = new Array();
+                if (c > 0x10000){
+                        // 4 bytes
+                    bs[0] = 0xF0 | ((c & 0x1C0000) >>> 18);
+                    bs[1] = 0x80 | ((c & 0x3F000) >>> 12);
+                    bs[2] = 0x80 | ((c & 0xFC0) >>> 6);
+                    bs[3] = 0x80 | (c & 0x3F);
+                }else if (c > 0x800){
+                         // 3 bytes
+                    bs[0] = 0xE0 | ((c & 0xF000) >>> 12);
+                    bs[1] = 0x80 | ((c & 0xFC0) >>> 6);
+                    bs[2] = 0x80 | (c & 0x3F);
+                }else if (c > 0x80){
+                       // 2 bytes
+                    bs[0] = 0xC0 | ((c & 0x7C0) >>> 6);
+                    bs[1] = 0x80 | (c & 0x3F);
+                }else{
+                        // 1 byte
+                    bs[0] = c;
+                }
+                for(var j=0; j<bs.length; j++){
+                    var b = bs[j];
+                    var hex = nibble_to_hex((b & 0xF0) >>> 4) 
+                            + nibble_to_hex(b &0x0F);
+                    buffer += '%'+hex;
+               }
+            }
+            return buffer;    
+             
         },
 
         /**
@@ -2432,10 +2486,10 @@ Roo.lib.Event = function() {
                             for (var j = 0; j < el.options.length; j++) {
                                 if (el.options[j].selected) {
                                     if (Roo.isIE) {
-                                        data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
+                                        data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
                                     }
                                     else {
-                                        data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
+                                        data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
                                     }
                                 }
                             }
@@ -2443,7 +2497,7 @@ Roo.lib.Event = function() {
                         case 'radio':
                         case 'checkbox':
                             if (el.checked) {
-                                data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
+                                data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(val) + '&';
                             }
                             break;
                         case 'file':
@@ -2457,12 +2511,12 @@ Roo.lib.Event = function() {
                             break;
                         case 'submit':
                             if(hasSubmit == false) {
-                                data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
+                                data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(val) + '&';
                                 hasSubmit = true;
                             }
                             break;
                         default:
-                            data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
+                            data += Roo.encodeURIComponent(name) + '=' + Roo.encodeURIComponent(val) + '&';
                             break;
                     }
                 }