|
2 | 2 |
|
3 | 3 | "http://evil.com/?http://good.com".match("https?://good.com"); // NOT OK |
4 | 4 | "http://evil.com/?http://good.com".match(new RegExp("https?://good.com")); // NOT OK |
5 | | - "http://evil.com/?http://good.com".match("^https?://good.com"); // OK |
6 | | - "http://evil.com/?http://good.com".match(/^https?:\/\/good.com/); // OK |
7 | | - "http://evil.com/?http://good.com".match("(^https?://good1.com)|(^https?://good2.com)"); // OK |
8 | | - "http://evil.com/?http://good.com".match("(https?://good.com)|(^https?://goodie.com)"); // NOT OK, but not detected |
| 5 | + "http://evil.com/?http://good.com".match("^https?://good.com"); // NOT OK - missing post-anchor |
| 6 | + "http://evil.com/?http://good.com".match(/^https?:\/\/good.com/); // NOT OK - missing post-anchor |
| 7 | + "http://evil.com/?http://good.com".match("(^https?://good1.com)|(^https?://good2.com)"); // NOT OK - missing post-anchor |
| 8 | + "http://evil.com/?http://good.com".match("(https?://good.com)|(^https?://goodie.com)"); // NOT OK - missing post-anchor |
9 | 9 |
|
10 | 10 | /https?:\/\/good.com/.exec("http://evil.com/?http://good.com"); // NOT OK |
11 | 11 | new RegExp("https?://good.com").exec("http://evil.com/?http://good.com"); // NOT OK |
|
23 | 23 | "https?://good.com", // NOT OK, referenced below |
24 | 24 | /https?:\/\/good.com/, // NOT OK, referenced below |
25 | 25 | new RegExp("https?://good.com"), // NOT OK, referenced below |
26 | | - "^https?://good.com" |
| 26 | + "^https?://good.com" // NOT OK - missing post-anchor |
27 | 27 | ]; |
28 | 28 | function isTrustedUrl(url) { |
29 | 29 | for (let trustedUrl of trustedUrls) { |
|
105 | 105 |
|
106 | 106 | /\.com|\.org/; // OK, has no domain name |
107 | 107 | /example\.com|whatever/; // OK, the other disjunction doesn't match a hostname |
108 | | - |
109 | | - /^https?:\/\/www\.example\.com\/.*\.html|^https?:\/\/www\.(?:example1|example2).com\/foo\/\d+\/\d+.html/i; // OK |
110 | 108 | }); |
0 commit comments