Ticket #1055 (closed New Feature: fixed)

Opened 9 months ago

Last modified 2 months ago

onerror handler for editing area

Reported by: swift Assigned to: 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

fckeditingarea.js (10.7 kB) - added by swift on 08/10/07 14:30:42.
1055.patch (2.3 kB) - added by martinkou on 03/11/08 10:38:19.
1055_2.patch (1.8 kB) - added by martinkou on 03/14/08 07:35:49.

Change History

08/10/07 14:30:42 changed by swift

  • attachment fckeditingarea.js added.

(follow-up: ↓ 4 ) 08/16/07 23:50:46 changed by alfonsoml

  • keywords deleted.

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.

(follow-up: ↓ 3 ) 08/23/07 12:10:07 changed 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.

(in reply to: ↑ 2 ) 08/23/07 12:55:43 changed 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.

(in reply to: ↑ 1 ) 08/23/07 12:58:37 changed 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.

09/29/07 00:26:02 changed 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)

09/29/07 16:20:01 changed by fredck

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

01/25/08 11:32:25 changed by w.olchawa

  • type changed from Bug to New Feature.

02/20/08 13:33:02 changed by w.olchawa

  • keywords set to Confirmed HasPatch.

03/11/08 09:24:44 changed 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.

03/11/08 10:38:19 changed by martinkou

  • attachment 1055.patch added.

03/11/08 10:38:34 changed by martinkou

  • keywords changed from Confirmed HasPatch to Confirmed HasPatch Review?.

03/13/08 12:46:26 changed by fredck

  • keywords changed from Confirmed HasPatch Review? to Confirmed HasPatch Review-.

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.

03/14/08 07:35:49 changed by martinkou

  • attachment 1055_2.patch added.

03/14/08 07:36:31 changed by martinkou

  • keywords changed from Confirmed HasPatch Review- to Confirmed HasPatch Review?.

Updated the patch according to Fred's suggestions.

03/14/08 17:02:43 changed by fredck

  • keywords changed from Confirmed HasPatch Review? to Confirmed HasPatch Review+.

03/17/08 04:37:29 changed by martinkou

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed with [1708].

Click here for more info about our SVN system.