Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 862a5b2

Browse files
Frank Thompsonfacebook-github-bot
Frank Thompson
authored andcommitted
fix pasting invalid links
Summary: I got a bug report today where someone was trying to copy/paste some content and nothing happened at all. I discovered that this was due to a bad link in her content, something like this: ``` <a href="https:// https://www.facebook.com">Faceboook</a> ``` In Chrome, this passes all the checks in `isValidAnchor`, but throws an error later on this line inside `_addAnchorNode`: ``` entityConfig.url = new URI(anchor.href).toString(); ``` To account for this, I added an explicit `URI.tryParseURI` inside `isValidAnchor`. Reviewed By: claudiopro Differential Revision: D22601322 fbshipit-source-id: 61cf050bb6e4a31bbe95995ad3f57e8f39a1d954
1 parent fc9395f commit 862a5b2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/model/encoding/convertFromHTMLToContentBlocks.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ const isValidAnchor = (node: Node) => {
161161
return false;
162162
}
163163
const anchorNode: HTMLAnchorElement = (node: any);
164-
return !!(
165-
anchorNode.href &&
164+
return (
165+
!!anchorNode.href &&
166+
URI.tryParseURI(anchorNode.href) != null &&
166167
(anchorNode.protocol === 'http:' ||
167168
anchorNode.protocol === 'https:' ||
168169
anchorNode.protocol === 'mailto:' ||

0 commit comments

Comments
 (0)