Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13607 closed Bug (invalid)

Copying text containing words marked as misspelled by SCAYT includes extra markup

Reported by: Eric Shepherd Owned by:
Priority: Normal Milestone:
Component: UI : Spell Checker Version:
Keywords: Cc:

Description

If you have spell check as you type (SCAYT) enabled and have text with the red squiggles underneath, denoting misspelled words, then select and copy that text, pasting the text into another document includes the <span>s used by SCAYT to add the red squiggles.

These should not be included in the text copied to the clipboard; they break the user's expected results and can contaminate content (especially if special components are used that require specific formatting of content).

Change History (7)

comment:1 Changed 4 years ago by Piotrek Koszuliński

I managed to reproduce it on Firefox (if you disable the ACF) and it would be reproducible on Chrome too if you disable the paste filter. However, it's not always possible to copy content with these squiggles because they often vanish on CTRL+A, CTRL+C or other actions. This was actually pretty odd and unstable behaviour.

I will report it on https://github.com/WebSpellChecker/ckeditor-plugin-scayt/issues because SCAYT is a 3rd party plugin. I need to figure out though, when it started appearing.

PS. After all these years I finally know that the thing below the incorrect words isn't underline, but squiggle :D This is my new favourite word.

comment:2 Changed 4 years ago by Eric Shepherd

Ah! I thought it was a third-party add-on but didn't know where to file the report so I started here.

This has been hosing our code samples; people copy code (which has SCAYT squiggles all through it due to code terms not being dictionary words) and paste it elsewhere, and those extra spans come along, resulting in a mess.

Worse is that pasted contents that include uses of our in-content macros (https://developer.mozilla.org/en-US/docs/MDN/Kuma/Introduction_to_KumaScript) will be broken because of spans inserted into the macro command text.

I'll keep an eye on that other bug. Thanks.

comment:3 in reply to:  1 Changed 4 years ago by Eric Shepherd

Replying to Reinmar:

I will report it on https://github.com/WebSpellChecker/ckeditor-plugin-scayt/issues because SCAYT is a 3rd party plugin. I need to figure out though, when it started appearing.

Let me know if you need me to report it. Otherwise, I'll just keep an eye on the SCAYT bug list to see if you get it filed :)

comment:4 Changed 4 years ago by Piotrek Koszuliński

Resolution: invalid
Status: newclosed
Version: 4.5.1

I reported https://github.com/WebSpellChecker/ckeditor-plugin-scayt/issues/104.

The workaround is to use the ACF or the paste filter to filter out SCAYT spans. Note that when ACF is enabled they are filtered automatically, so this issue actually happens only when ACF is disabled or very loosely configured. In such case the configuration should be improved by tightening it or by using this trick How to allow everything except....

Last edited 4 years ago by Piotrek Koszuliński (previous) (diff)

comment:5 Changed 4 years ago by Piotrek Koszuliński

I've checked that configuring editor this way won't work:

			CKEDITOR.replace( 'editor1', {
				allowedContent: {
					$1: {
					// Use the ability to specify elements as an object.
					elements: CKEDITOR.dtd,
					attributes: true,
					styles: true,
					classes: true
					}
				},
				disallowedContent: 'span(scayt-*)[data-scayt-*]'
			} );

That's because spans without any classes and data attributes will still leak. That's bad... but basically we've tried here to abuse ACF a little bit, so it may happen.

However, two other tricks will do the job.

First uses the fact that paste filter works separately from ACF. It will leave spans without any attributes too, but these spans will be removed by the next processors:

			CKEDITOR.replace( 'editor1', {
				pasteFilter: {
					$1: {
					// Use the ability to specify elements as an object.
					elements: CKEDITOR.dtd,
					attributes: true,
					styles: true,
					classes: true
					}
				},
				on: {
					pluginsLoaded: function( evt ) {
						evt.editor.pasteFilter.disallow( 'span(scayt-*)[data-scayt-*]' );
					}
				}
			} );

Or, simply use the dataProcessor. This is the best solution as it will also be applied to invalid data (that might have been saved into DB because of this bug):

			CKEDITOR.replace( 'editor1', {
				on: {
					pluginsLoaded: function( evt ) {
						evt.editor.dataProcessor.dataFilter.addRules( {
							elements: {
								span: function( el ) {
									if ( el.attributes[ 'data-scayt-word' ] ) {
										// Remove the element without removing its content.
										delete el.name;
									}
								}
							}
						} );
					}
				}
			} );

comment:6 Changed 4 years ago by Eric Shepherd

Reinmar: Where's the best place to put this snippet, given what you already know of our code?

comment:7 Changed 4 years ago by Piotrek Koszuliński

@Sheppy: I'll contact you via email.

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