Ticket #5338 (closed Bug: fixed)

Opened 5 years ago

Last modified 4 years ago

Paste from Open Office causes error

Reported by: drhe Owned by: fredck
Priority: Normal Milestone: CKEditor 3.4
Component: Core : Pasting Version: 3.2
Keywords: Confirmed HasPatch Cc: miquel@…, gandhi007

Description

When pasting from Open Office into CKEditor in Firefox, an error is thrown when attempting to save or use the Source button.

The error is in plugins/htmldataprocessor/plugin.js line 192:

element.children[ 0 ].value = element.attributes[ '_cke_title' ];

element.attributes._cke_title is undefined

It is possible that this error is a consequence of the empty title element which Open Office creates.

Note that this error does not occur in Chromium 5.0.330.0, which is the only other browser I have tested in.

To reproduce:

  • Create a document in Open Office
  • Copy some content from it
  • Paste it into a CKEditor instance in Firefox
  • Click the 'Source' button

Using:

  • CKEditor 3.2 (also tested on Nightly)
  • Firefox 3.5.8 (Ubuntu 8.10)
  • Open Office 3.11

Attachments

5338.patch (538 bytes) - added by fredck 4 years ago.

Change History

comment:1 Changed 5 years ago by drhe

By 'Ubuntu 8.10' I meant, of course, Ubuntu 9.10

Sorry!

comment:2 Changed 5 years ago by kubak

  • Component changed from General to Core : Pasting
  • Milestone set to CKEditor 3.x

It's not only the problem of this error. When pasting from OpenOffice to CKEditor data from the field are not going with POST on submit - data aren't saving in the CKEditor area.

comment:3 Changed 5 years ago by gaellafond

Bug confirm on Windows XP

  • CKEditor 3.2 and 3.2.1
  • Firefox
  • OpenOffice

The Bug do NOT occur with:

  • OpenOffice + IE

nor

  • MsWord + Firefox

It's specific to OO and Firefox.

NOTE: Tested with the demo pages:
3.2: http://ckeditor.com/demo
3.2.1: http://nightly.ckeditor.com/5375/ckeditor.js

comment:4 Changed 5 years ago by shellsterdude

I have confirmed/experienced this bug in Windows XP as well. I have confirmed everything that gaellafond stated above.

comment:5 Changed 5 years ago by mrtorrent

  • Cc miquel@… added

comment:6 Changed 5 years ago by alfonsoml

  • Cc gandhi007 added

#5624 has been marked as dup

comment:7 follow-up: ↓ 9 Changed 5 years ago by aogon

quick fix:

if( element != undefined && element.children != undefined && element.children[ 0 ] != undefined ) element.children[ 0 ].value = (element.attributes[ '_cke_title' ]==undefined ? element.attributes[ '_cke_title' ] : '');

this should do the trick :)

comment:8 Changed 5 years ago by fredck

  • Milestone changed from CKEditor 3.x to CKEditor 3.4

Maybe we have a better solution for it.

comment:9 in reply to: ↑ 7 Changed 5 years ago by gaellafond

Replying to aogon:

quick fix:

if( element != undefined && element.children != undefined && element.children[ 0 ] != undefined ) element.children[ 0 ].value = (element.attributes[ '_cke_title' ]==undefined ? element.attributes[ '_cke_title' ] : '');

this should do the trick :)

Thanks, it's working.
I think you invert the elements on your conditional statement:

(element.attributes[ '_cke_title' ]==undefined ? element.attributes[ '_cke_title' ] : '')

should be

(element.attributes[ '_cke_title' ]==undefined ? '' : element.attributes[ '_cke_title' ])

comment:10 Changed 5 years ago by gaellafond

NOTE:
FYI the patch has to be apply on the file:

ckeditor/_source/plugins/htmldataprocessor/plugin.js

You also need to run CKEditor from source:

<script type="text/javascript" src="ckeditor/ckeditor_source.js"></script>

instead of

<script type="text/javascript" src="ckeditor/ckeditor.js"></script>

comment:11 Changed 5 years ago by garry.yao

  • Keywords Confirmed added
  • Status changed from new to assigned
  • Owner set to garry.yao

Thanks for the efforts all, but please check this page when contributing.

Here, we need a dedicate processing for Oo, just like we [ http://dev.fckeditor.net/browser/CKEditor/trunk/_source/plugins/pastefromword/filter/default.js#L1104

did] for MS-Word, where basic cleanup is required since Oo is not doing as well as MS Office in the sense of dealing with clipboard.

comment:12 Changed 5 years ago by fredck

For now, we must simply avoid the js error.

comment:13 Changed 5 years ago by tehek

  • Version changed from 3.2 to 3.3.1

The same issue persists with: CKEditor 3.3.1 Firefox 3.6.3 (Windows Vista) Open Office 3.2.0


To hotfix it in your ckeditor.js :

Find the following string:

title:function(Q){Q.children[0].value=Q.attributes._cke_title;}}

And replace it with:

title:function(Q){if(Q&&Q.children&&Q.children[0])Q.children[0].value=Q.attributes._cke_title||'';}}

In _sources/plugins/htmldataprocessor/plugin.js:

Find lines 202-205:

title : function( element )
{
	element.children[ 0 ].value = element.attributes[ '_cke_title' ];
}

replace with:

title : function( element )
{
	if ( element && element.children && element.children[0])
		element.children[ 0 ].value = element.attributes[ '_cke_title' ] || '';
}

Basically the method "title" doesn't check if the passed argument is an existing node. This hotfix performs a basic check and returns empty string if element.attributes[ '_cke_title' ] is not set.

comment:14 Changed 5 years ago by alfonsoml

  • Version changed from 3.3.1 to 3.2

comment:15 Changed 5 years ago by fredck

  • Keywords HasPatch added

Changed 4 years ago by fredck

comment:16 Changed 4 years ago by fredck

  • Status changed from assigned to review
  • Owner changed from garry.yao to fredck

comment:17 Changed 4 years ago by Saare

  • Status changed from review to review_passed

comment:18 Changed 4 years ago by fredck

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

Fixed with [5739].

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