Paste: only link selection if URL protocol is http(s) - #53000
Merged
Conversation
ellatrix
requested review from
Mamaduka,
dcalhoun,
fluiddot and
kevin940726
as code owners
July 26, 2023 21:02
|
Size Change: +27 B (0%) Total Size: 1.65 MB
ℹ️ View Unchanged
|
Member
Member
Author
Imo no, it's better to let the user add these explicitly since these are much rarer. |
jorgefilipecosta
approved these changes
Oct 9, 2023
jorgefilipecosta
left a comment
Member
There was a problem hiding this comment.
The change looks good to me and fixes the issue.
ellatrix
force-pushed
the
fix/link-selection-http
branch
from
October 10, 2023 07:27
4d3d9cc to
1191fd8
Compare
|
Flaky tests detected in 1191fd8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6466079195
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Fixes #24895.
isURLreturns true for any sort of protocol, which results in false positives such asmovie: something, wheremoviewould be assumed as the protocol. To leave the flexibility ofisURLand avoid changing this API, we can just add an additional check if the protocol is http(s) for just the link pasting feature. In this case, it's only really meant for these two protocols.If there's more demand, we could add an argument to
isURLin the future to check for whitelisted protocols.OR we could return the URL instance so you can check as follows:
OR we just use
new URL( text )directly. What do you think?Anyway, this needs to be fixed, we can thing about the best approach later.
Why?
Pasting anything with a colon over a selection results in a link.
How?
Described above.
Testing Instructions
Copy anything with a colon and paste over a selection. An e2e test has been added.
Testing Instructions for Keyboard
Screenshots or screencast