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

Raw Handling: Text with colon incorrectly interpreted as a link #24895

Closed
thomashigginbotham opened this issue Aug 28, 2020 · 8 comments · Fixed by #53000 · May be fixed by #28534
Closed

Raw Handling: Text with colon incorrectly interpreted as a link #24895

thomashigginbotham opened this issue Aug 28, 2020 · 8 comments · Fixed by #53000 · May be fixed by #28534
Assignees
Labels
[Feature] Paste [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable Needs Dev Ready for, and needs developer efforts [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@thomashigginbotham
Copy link

Describe the bug
When pasting over existing text, if the new text has a colon in it without first having a space character, Gutenberg will assume you are pasting a link and will open the link insertion dialog box.

To reproduce
Steps to reproduce the behavior:

  1. Add some text to a paragraph block.
  2. Copy the following text to your clipboard: Bug: This text is not a link
  3. Select the text you added to the paragraph block.
  4. Paste the text you copied.
  5. Notice that you are prompted to insert a link.

Expected behavior
The text should paste without inserting it as a link.

Screenshots
paste-text-link-bug

Editor version (please complete the following information):

  • WordPress version: 5.5
  • Does the website has Gutenberg plugin installed, or is it using the block editor that comes by default? default

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version 84
@mtias mtias added [Feature] Paste [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Type] Bug An existing feature does not function as intended labels Aug 29, 2020
@kirilzh
Copy link
Contributor

kirilzh commented Aug 31, 2020

Seems like the problem is in

export function isURL( url ) {
// A URL can be considered value if the `URL` constructor is able to parse
// it. The constructor throws an error for an invalid URL.
try {
new URL( url );
return true;
} catch {
return false;
}
}

new URL doesn't throw. Maybe we can use valid-url dependency?

@kishanjasani
Copy link
Contributor

@kirilzh there is an issue with isURL.

Is there we are using any packages for the check URL is valid or not? or maybe we can create an additional check here for validating URL.

@mrclay
Copy link

mrclay commented Jan 25, 2021

I suggest just returning FALSE if the successfully parsed URL pathname begins with whitespace. Or the scheme begins with a capital letter but is not all caps. Otherwise you get in the business of the big list of established URI schemes.

@mrclay
Copy link

mrclay commented Jan 25, 2021

I can submit a PR on branch 7.7.0 but the master branch fails in attempt to patch xcode (I'm on linux).

@talldan
Copy link
Contributor

talldan commented Jul 21, 2021

There was a similar fix here that it might be possible to take inspiration from - #32663

The difference here is that this problem is pasting something that looks like a link over an existing text selection, whereas that other issue fixed a problem when highlighting text that looks like a link and selecting the link button.

@ndiego
Copy link
Member

ndiego commented Jul 12, 2022

I have been able to reproduce this.

@R33D3M33R
Copy link

Hi,

what a horrible "feature". When you select text and paste something, you want to replace it with the pasted content. You have a button to make a link ...

@annezazu
Copy link
Contributor

Noting that I can replicate this with 6.3 RC 1.

@annezazu annezazu changed the title Gutenberg incorrectly interprets pasted text as a link Raw Handling: Text with colon incorrectly interpreted as a link Jul 19, 2023
@annezazu annezazu added the Needs Dev Ready for, and needs developer efforts label Aug 3, 2023
@annezazu annezazu moved this to In Progress in WordPress 6.4 Editor Tasks Aug 30, 2023
@annezazu annezazu moved this from In Progress to Punted to 6.5 in WordPress 6.4 Editor Tasks Sep 25, 2023
@github-project-automation github-project-automation bot moved this from Punted to 6.5 to Done in WordPress 6.4 Editor Tasks Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Paste [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable Needs Dev Ready for, and needs developer efforts [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Done
10 participants