Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit bfec9eb

Browse files
committed
Do not linkify javascript: URLs
1 parent 33f2d9f commit bfec9eb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/devtools-reps/src/reps/rep-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
// Dependencies
6-
const validProtocols = /^(http|https|ftp|data|javascript|resource|chrome):/i;
6+
const validProtocols = /^(http|https|ftp|data|resource|chrome):/i;
77
const tokenSplitRegex = /(\s|\'|\"|\\)+/;
88
const ELLIPSIS = "\u2026";
99
const dom = require("react-dom-factories");

packages/devtools-reps/src/reps/tests/string-with-url.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,4 +452,15 @@ describe("test String with URL", () => {
452452
link.simulate("click");
453453
expect(openLink).toBeCalledWith(url);
454454
});
455+
456+
it("does not render links for js URL", () => {
457+
const url = "javascript:x=42";
458+
const string = `${url} some other text`;
459+
460+
const openLink = jest.fn();
461+
const element = renderRep(string, {openLink, useQuotes: false});
462+
expect(element.text()).toEqual(string);
463+
const link = element.find("a");
464+
expect(link.exists()).toBe(false);
465+
});
455466
});

0 commit comments

Comments
 (0)