Opened 10 years ago

Closed 9 years ago

#1055 closed New Feature (fixed)

onerror handler for editing area

Reported by: Alexander Owned by: Martin Kou
Priority: Normal Milestone: FCKeditor 2.6
Component: General Version: FCKeditor 2.4.3
Keywords: Confirmed HasPatch Review+ Cc:

Description

In FCKEditingArea one can see the commented lines with a todo task.

// IE: Avoid JavaScript errors thrown by the editing are source (like tags events).
// TODO: This error handler is not being fired.
// this.Window.onerror = function() { alert( 'Error!' ) ; return true ; }

Fortunately I've found a possible solution. An error handler can be attached to the iframe's content window by adding the script tag that does it during the rendering of iframe's body (see below). It seems that the dynamic attaching of the handler is not implemented in IE.

var oDoc = this.Document = this.Window.document ;

oDoc.open() ;
oDoc.write('<script>window.onerror = function() { alert( 'Error!' ) ; return true ; };</scr'+'ipt>') ;
oDoc.write( html ) ;
oDoc.close() ;

Attachments (3)

fckeditingarea.js (10.7 KB) - added by Alexander 10 years ago.
1055.patch (2.3 KB) - added by Martin Kou 9 years ago.
1055_2.patch (1.8 KB) - added by Martin Kou 9 years ago.

Download all attachments as: .zip

Change History (17)

Changed 10 years ago by Alexander

Attachment: fckeditingarea.js added

comment:1 Changed 10 years ago by Alfonso Martínez de Lizarrondo

Keywords: onerror editing area todo removed

It's interesting, but the events of tags are already protected as well as any other javascript code, so I don't know if it's really useful.

On the other side, I think that there is a bug about javascript errors in the Paste dialog, maybe it could be applied there.

comment:2 Changed 10 years ago by Alexander

Actually, FCKeditor 2.4.3 has an issue where the events of tags are not protected and serve as possible script errors source. That's I've deeped in this problem.

comment:3 in reply to:  2 Changed 10 years ago by Frederico Caldeira Knabben

Replying to swift:

Actually, FCKeditor 2.4.3 has an issue where the events of tags are not protected and serve as possible script errors source. That's I've deeped in this problem.

You are actually adding another issue here... do you have an example of event that is not getting protected? The protections is important not only to avoid errors, but also to avoid executing event scripts in the editing area.

comment:4 in reply to:  1 Changed 10 years ago by Frederico Caldeira Knabben

Milestone: FCKeditor 2.6

Replying to alfonsoml:

It's interesting, but the events of tags are already protected as well as any other javascript code, so I don't know if it's really useful.

Maybe we should include it just for safety... the "Who knows?" fashion.

On the other side, I think that there is a bug about javascript errors in the Paste dialog, maybe it could be applied there.

Good point Alfonso. It could be useful there, and we should give it a try.

comment:5 Changed 10 years ago by Alfonso Martínez de Lizarrondo

That bug was #389, and now it's fixed.

Thanks.

(don't know if this bug now should be left open or nothing will be done for the main area)

comment:6 Changed 10 years ago by Frederico Caldeira Knabben

I think this change is quite small, so we could consider it just to be safe.

comment:7 Changed 10 years ago by Wojciech Olchawa

Type: BugNew Feature

comment:8 Changed 9 years ago by Wojciech Olchawa

Keywords: Confirmed HasPatch added

comment:9 Changed 9 years ago by Martin Kou

Owner: set to Martin Kou
Status: newassigned

Although the patch works, it is interfering with the HTML source code in full page editing mode. So some additional changes would be needed to make this work.

Changed 9 years ago by Martin Kou

Attachment: 1055.patch added

comment:10 Changed 9 years ago by Martin Kou

Keywords: Review? added

comment:11 Changed 9 years ago by Frederico Caldeira Knabben

Keywords: Review- added; Review? removed

The "FCK_IGNORE" makes the patch a hole ugly hack. Not good.

Fortunately, there is another solution to achieve the same results: adding the "_fcktemp" attribute to the tag. Also, adding "type" is not a bad idea.

So, it should be enough to change the following in the patch:

var sOverrideError = '<script type="text/javascript" _fcktemp="true">window.onerror=function(){return true;};</script>' ;

Removing all changes from fck.js.

Changed 9 years ago by Martin Kou

Attachment: 1055_2.patch added

comment:12 Changed 9 years ago by Martin Kou

Keywords: Review? added; Review- removed

Updated the patch according to Fred's suggestions.

comment:13 Changed 9 years ago by Frederico Caldeira Knabben

Keywords: Review+ added; Review? removed

comment:14 Changed 9 years ago by Martin Kou

Resolution: fixed
Status: assignedclosed

Fixed with [1708].

Click here for more info about our SVN system.

Note: See TracTickets for help on using tickets.
© 2003 – 2017 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy