-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-h4w9-6x78-8vrj
Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> fix tests/lint Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>
- Loading branch information
1 parent
8fe9a58
commit 8bc3ef6
Showing
4 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
20 changes: 20 additions & 0 deletions
20
ui/src/app/applications/components/application-urls.test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {ExternalLink, InvalidExternalLinkError} from './application-urls'; | ||
|
||
test('rejects malicious URLs', () => { | ||
expect(() => { | ||
const _ = new ExternalLink('javascript:alert("hi")'); | ||
}).toThrowError(InvalidExternalLinkError); | ||
expect(() => { | ||
const _ = new ExternalLink('data:text/html;<h1>hi</h1>'); | ||
}).toThrowError(InvalidExternalLinkError); | ||
}); | ||
|
||
test('allows absolute URLs', () => { | ||
expect(new ExternalLink('https://localhost:8080/applications').ref).toEqual('https://localhost:8080/applications'); | ||
}); | ||
|
||
test('allows relative URLs', () => { | ||
// @ts-ignore | ||
window.location = new URL('https://localhost:8080/applications'); | ||
expect(new ExternalLink('/applications').ref).toEqual('/applications'); | ||
}); |
This file contains 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