-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(core) Restrict widget/form URL schemes
Summary: Custom widget and form redirect URLs were not restricted to http[s] schemes, leaving the door open to vulnerabilities from injection attacks. URLs are now properly sanitized. Test Plan: Browser and unit tests. Reviewers: dsagal Reviewed By: dsagal Subscribers: dsagal, jordigh, paulfitz, fflorent Differential Revision: https://phab.getgrist.com/D4410
- Loading branch information
1 parent
efefc96
commit 10b0690
Showing
7 changed files
with
144 additions
and
27 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
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
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,24 @@ | ||
import { sanitizeUrl } from "app/common/urlUtils"; | ||
import { assert } from "chai"; | ||
|
||
describe("urlUtils", function () { | ||
describe("sanitizeUrl", function () { | ||
it("returns the provided URL if the scheme is http[s]", function () { | ||
assert.equal(sanitizeUrl("https://example.com"), "https://example.com/"); | ||
assert.equal(sanitizeUrl("http://example.com"), "http://example.com/"); | ||
assert.equal(sanitizeUrl("https://example.com"), "https://example.com/"); | ||
}); | ||
|
||
it("returns null if the provided URL is invalid", function () { | ||
assert.isNull(sanitizeUrl("www.example.com")); | ||
assert.isNull(sanitizeUrl("")); | ||
assert.isNull(sanitizeUrl("invalid")); | ||
}); | ||
|
||
it("returns null if the provided URL's scheme is not http[s]", function () { | ||
assert.isNull(sanitizeUrl("mailto:[email protected]")); | ||
assert.isNull(sanitizeUrl("ftp://getgrist.com/path")); | ||
assert.isNull(sanitizeUrl("javascript:alert()")); | ||
}); | ||
}); | ||
}); |
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