Opened 16 years ago
Closed 16 years ago
#2754 closed Bug (fixed)
CKEditor v3 enters infinite loop when trying to output HTML code
Reported by: | Martin Kou | Owned by: | Martin Kou |
---|---|---|---|
Priority: | Must have (possibly next milestone) | Milestone: | CKEditor 3.0 |
Component: | Core : Output Data | Version: | SVN (FCKeditor) - Retired |
Keywords: | Confirmed Review+ | Cc: |
Description (last modified by )
To reproduce the bug:
- Open replacebyclass.html in the samples in Firefox 3.
- Also open http://gplv3.fsf.org/ in Firefox 3.
- Copy everything in FSF's page into the editing area.
- Click "Source" - the browser freezes.
This is not a performance problem with the new code - I've tried pasting the long text of GPL v3 in the editor area and the speed of switching to source mode is noticeable faster than v2.
Preliminary tests showed that the infinite loop is from the HTML data processor plugin.
Attachments (2)
Change History (12)
comment:1 Changed 16 years ago by
Keywords: | Confirmed added |
---|
comment:2 Changed 16 years ago by
Description: | modified (diff) |
---|
comment:3 Changed 16 years ago by
Owner: | set to Martin Kou |
---|---|
Status: | new → assigned |
comment:4 Changed 16 years ago by
comment:5 Changed 16 years ago by
Priority: | Normal → High |
---|
Put to high priority for the beta release.
Changed 16 years ago by
Attachment: | 2754.patch added |
---|
comment:6 Changed 16 years ago by
The loop was found to be caused by the HTML parser's "htmlParts" regular expression - it doesn't expect comments to contain newlines.
comment:7 Changed 16 years ago by
Keywords: | Review? added |
---|
comment:8 Changed 16 years ago by
Keywords: | Review- added; Review? removed |
---|
Martin, the correct replacement for .
is [\S\s]
, not (?:\s|\S)
. In this way you replace a character set reference by another character set reference, instead of a matching group (performs better, theoretically).
Changed 16 years ago by
Attachment: | 2754_2.patch added |
---|
comment:9 Changed 16 years ago by
Keywords: | Review? added; Review- removed |
---|
comment:10 Changed 16 years ago by
Keywords: | Review+ added; Review? removed |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
I've committed the patch with [2918]. I did that after the review, to avoid delay in the release.
I've changed that part of the regex to [\S\s]
, instead of [\s\S]
. You gonna think I'm crazy, but as I can't explain precisely how browsers implement their regex engines, I'm assuming the case where that match means "find a character from the \S group (first check) or a character from the \s group (second check)". So, as we have more characters than spaces inside comments (usually), there is a theoretical performance difference by changing the order the characters are presented into the square brackets. And yes... you really gonna think I'm crazy.
Here's the HTML string in the page that causes the freeze: