PDA

View Full Version : [OPEN] [Ext 4.0.7] HtmlEditor#cleanHtml bug and fix



srfarley
21 Nov 2011, 8:18 AM
HtmlEditor contains a method called cleanHtml() containing the following code:

if (html.charCodeAt(0) === this.defaultValue.replace(/\D/g, '')) {
html = html.substring(1);
}

The problem is that this comparison will always return false because charCodeAt() returns an integer, replace() returns a string, and the strict equality operator is being used. As a result, the default value will not be stripped from the HTML string, and an invisible character will be left in the value returned by getValue().

The fix is to convert the result of the string replacement to an integer:

if (html.charCodeAt(0) === parseInt(this.defaultValue.replace(/\D/g, ''), 10)) {
html = html.substring(1);
}

mitchellsimoens
21 Nov 2011, 12:15 PM
Thank you for the report. We will look into this!

evant
21 Nov 2011, 2:07 PM
That's exactly what we have in 4.1! Great minds eh? ;)



if (html.charCodeAt(0) === parseInt(this.defaultValue.replace(/\D/g, ''), 10)) {