-
Notifications
You must be signed in to change notification settings - Fork 27
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
protects against invalid Quill links #1502
Conversation
➕ 1 for this feature! We've had this come up a few times in the last couple of weeks. |
The default behavior when parsing a link in Quill: 1. Check if link matches a list of valid protocols. 2. If not, change link text to `about:blank`. Kiln wraps the `Link.sanitize` function to prepend `http://` in front of any link missing a protocol. As a result we can end up with invalid links like this: ``` "http://one two three" ``` This commit preserves the convenience factor of not **requiring** end users to enter a protocol, but validates that the link produced is a valid URL. Invalid URLs will revert to `about:blank`. This commit also changes the default protocol to `https://` which is a reasonable expectation and more secure default.
fbd7b88
to
b76df32
Compare
|
@macgyver I agree that it's not ideal, but it is more useful than a completely broken link (clicking it won't take take the end user away from the page to an unintended URL, including This behavior is just the default behavior of Quill. A more robust fix that deletes the link entirely would require some patching of Quill internals from what I could glean from a little experimentation. Quill doesn't expose the I'm open to suggestions / PRs for a full link deletion and will add an issue to the backlog so that an ideal fix stays on our radar. This may be something better fixed in the Quill source itself, I'll see if there has been any discussion surrounding the |
duplicating the default behavior of Quill doesn't seem like a virtue in this case - also fwiw I think a more comprehensive fix is to inform the CMS user, via a page or component validator, that the page contains invalid links so they can fix the issue before publishing. This isn't really something we can fix in code, we can't know what the CMS user was thinking when they entered a bad link, all we can do is inform them that it won't work and give them the ability to fix it themselves. |
@macgyver I see what you mean about AMP. In that case, I'm working on creating an issue outlining the feature request. It sounds like the lowest level of effort would be to skip creating the anchor tags for invalid links. I'll link the issue here to capture this discussion and provide a new location for further discussion. Thanks for your input on this. |
The default behavior when parsing a link in Quill:
about:blank
.Kiln wraps the
Link.sanitize
function to prependhttp://
in frontof any link missing a protocol.
As a result we can end up with invalid links like this:
This commit preserves the convenience factor of not requiring end
users to enter a protocol, but validates that the link produced is a
valid URL. Invalid URLs will revert to
about:blank
.This commit also changes the default protocol to
https://
which is areasonable expectation and more secure default.