Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected HTML escape character translation errors during pasting and source code switching #15036

Closed
letsbug opened this issue Sep 21, 2023 · 10 comments · Fixed by #15231
Closed
Assignees
Labels
package:clipboard squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@letsbug
Copy link

letsbug commented Sep 21, 2023

📝 Provide detailed reproduction steps (if any)

  1. Copy a link string that contains HTML escape characters, such as “https://example.com/about?param=1&timestamp=times”
  2. Paste this link into any of CKEditor's builds

✔️ Expected result

What I want is the original link I copied.

❌ Actual result

But i got the following result:
https://example.com/about?param=1xtamp=times

❓ Possible solution

If you have ideas, you can list them here. Otherwise, you can delete this section.

📃 Other details

  • Browser: …
  • OS: …
  • First affected CKEditor version: …
  • Installed CKEditor plugins: …

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@letsbug letsbug added the type:bug This issue reports a buggy (incorrect) behavior. label Sep 21, 2023
@Reinmar
Copy link
Member

Reinmar commented Sep 21, 2023

Also, as a link's href:

Works for me. Unless you mean some other use case?

@Reinmar Reinmar added the pending:feedback This issue is blocked by necessary feedback. label Sep 21, 2023
@letsbug
Copy link
Author

letsbug commented Sep 22, 2023

I'm not sure what triggers it, here is a screen recording of my actions:

CleanShot 2023-09-22 at 15 58 37

@Witoso
Copy link
Member

Witoso commented Sep 25, 2023

We still cannot reproduce it. Please check with the bare browser with no extensions (e.g, incognito). It's possible that somehow your clipboard content was changed by something.

@letsbug
Copy link
Author

letsbug commented Oct 6, 2023

It's fine on just one device, but what confuses me is that I have the same problem on other devices. I recorded this using incognito mode on another device:

Screen Recording 2023-10-06 at 23 50 15

ps: I've tried it with a previously installed virtual machine, and it's the same problem. No other software is installed, using a built-in browser.

@letsbug
Copy link
Author

letsbug commented Oct 6, 2023

Here are the results from another device:

录屏2023-10-07 00 50 15

@Witoso
Copy link
Member

Witoso commented Oct 9, 2023

I recommend checking the clipboard's content, I, personally, use Pasteboard viewer.

@letsbug
Copy link
Author

letsbug commented Oct 10, 2023

This is the result of checking with Pasteboard viewer

CleanShot 2023-10-10 at 16 07 48@2x

@Witoso
Copy link
Member

Witoso commented Oct 16, 2023

I reproduced this on the latest Safari/Chrome when using the option "Copy Link Address".

@Witoso
Copy link
Member

Witoso commented Oct 16, 2023

This is interesting, is it possible that the & char is joined with a few more chars, and produce a new one, like x (unicode addition?)

Another example:

https://github.com/ckeditor/ckeditor5/issues/15036#issuecomment-1754653408?param1=asd&param2=gdfg

Creates after pasting:

https://github.com/ckeditor/ckeditor5/issues/15036#issuecomment-1754653408?param1=asd¶m2=gdfg

@niegowski any thoughts?

@niegowski
Copy link
Contributor

Looks like plainTextToHtml() should escape all & characters but currently it does not.

export default function plainTextToHtml( text: string ): string {
text = text
// Encode <>.
.replace( /</g, '&lt;' )
.replace( />/g, '&gt;' )
// Creates a paragraph for each double line break.
.replace( /\r?\n\r?\n/g, '</p><p>' )
// Creates a line break for each single line break.
.replace( /\r?\n/g, '<br>' )
// Replace tabs with four spaces.
.replace( /\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;' )
// Preserve trailing spaces (only the first and last one – the rest is handled below).
.replace( /^\s/, '&nbsp;' )
.replace( /\s$/, '&nbsp;' )
// Preserve other subsequent spaces now.
.replace( /\s\s/g, ' &nbsp;' );

@Witoso Witoso added squad:core Issue to be handled by the Core team. package:clipboard and removed pending:feedback This issue is blocked by necessary feedback. labels Oct 16, 2023
@CKEditorBot CKEditorBot added the status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. label Oct 18, 2023
@mmotyczynska mmotyczynska self-assigned this Oct 24, 2023
@CKEditorBot CKEditorBot added status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. and removed status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. labels Oct 24, 2023
niegowski added a commit that referenced this issue Oct 25, 2023
…pe-characters

Fix (clipboard): Pasting a link address should not convert its parts that look like HTML entities. Closes #15036.
@CKEditorBot CKEditorBot removed the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Oct 25, 2023
@CKEditorBot CKEditorBot added this to the iteration 68 milestone Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:clipboard squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants