FCKeditor v2.4.3 Firefox "script stack space quota is exhausted" fixed !

Hi all,

I was uploading a document of about 10 MB doc in FCKeditor v 2.4.3 from server. In IE it works fine but for the Firefox v>2.0 , I was getting this strange bug "script stack space quota is exhausted" . Thought it was inherent firefox problem, But why did FCKeditor caused it ?

After reading the code and having some inline tests , I found that the following code in
fckeditorcode_ie.js FCKeditor start function caused this problem,


/* Buggy regex match for body contents*/
/* Results in "script stack space quota is exhausted" for large documents*/

var G=A.match(FCKRegexLib.BeforeBody);
var H=A.match(FCKRegexLib.AfterBody);
if (G&&H){
var I=A.substr(G[1].length,A.length-G[1].length-H[1].length);
A=G[1]+' '+H[1];
if (FCKBrowserInfo.IsGecko&&(I.length==0||FCKRegexLib.EmptyParagraph.test(I)))
I='
';
this._BodyHTML=I;
}else
this._BodyHTML=A;
};


Here the regex match for stripping the before body and after body elements is the main problem which makes the firefox browser to run out of the memory for large documents.

I replaced the regex match with indexOf to find out start and end of the body tags and stripped it , it solved this problem.

Here is the fixed code.


/*fixed the memory problem using indexOf in mozilla browsers*/
if (FCKBrowserInfo.IsIE)
A=A.replace(/(]*?)\s*\/?>(?!\s*<\/base>)/gi,'$1>');
else if (!B){
var G=A.indexOf("");
var H=A.indexOf("");
if (G!=-1&&H!=-1){
var I=A.substr(G,H);
//A=G[1]+' '+H[1];
if (FCKBrowserInfo.IsGecko&&(I.length==0||FCKRegexLib.EmptyParagraph.test(I)))
I='
';
this._BodyHTML=I;
}else
this._BodyHTML=A;
};



I don't see a fix for this in the future versions also , Is this fixed in CKEditor3.0 ? If not please FCKeditor guys save the developer man days ..............

Comments

Popular posts from this blog

Hibernate queries are slow ! SQL Server's are not my type ? - Here is what you need to know!

IFTTT Service descriptions with Google Search

Detecting browser event closing in Javascript