Opened 9 years ago

Closed 9 years ago

#1055 closed New Feature (fixed)

onerror handler for editing area

Reported by: swift Owned by: martinkou
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 swift 9 years ago.
1055.patch (2.3 KB) - added by martinkou 9 years ago.
1055_2.patch (1.8 KB) - added by martinkou 9 years ago.

Download all attachments as: .zip

Change History (17)

Changed 9 years ago by swift

comment:1 follow-up: Changed 9 years ago by alfonsoml

  • 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 follow-up: Changed 9 years ago by 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.

comment:3 in reply to: ↑ 2 Changed 9 years ago by fredck

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 9 years ago by fredck

  • Milestone set to 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 9 years ago by alfonsoml

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 9 years ago by fredck

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

comment:7 Changed 9 years ago by w.olchawa

  • Type changed from Bug to New Feature

comment:8 Changed 9 years ago by w.olchawa

  • Keywords Confirmed HasPatch added

comment:9 Changed 9 years ago by martinkou

  • Owner set to martinkou
  • Status changed from new to assigned

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 martinkou

comment:10 Changed 9 years ago by martinkou

  • Keywords Review? added

comment:11 Changed 9 years ago by fredck

  • 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 martinkou

comment:12 Changed 9 years ago by martinkou

  • Keywords Review? added; Review- removed

Updated the patch according to Fred's suggestions.

comment:13 Changed 9 years ago by fredck

  • Keywords Review+ added; Review? removed

comment:14 Changed 9 years ago by martinkou

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed with [1708].

Click here for more info about our SVN system.

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