-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check of unsafe HTML in SVG files (#3250)
* Check of unsafe HTML in SVG files Fixes #3249 * mention in index.html file * feedbacked
- Loading branch information
Showing
5 changed files
with
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const { checkFile } = require("../../filecheck/checker"); | ||
|
||
const SAMPLES_DIRECTORY = path.join(__dirname, "samplefiles"); | ||
|
||
describe("checking files", () => { | ||
it("should spot SVGs with scripts inside them", async () => { | ||
const filePath = path.join(SAMPLES_DIRECTORY, "script.svg"); | ||
// Sanity check the test itself | ||
console.assert(fs.existsSync(filePath), `${filePath} does not exist`); | ||
await expect(checkFile(filePath)).rejects.toThrow( | ||
"contains a <script> tag" | ||
); | ||
}); | ||
it("should spot SVGs with onLoad inside an element", async () => { | ||
const filePath = path.join(SAMPLES_DIRECTORY, "onhandler.svg"); | ||
// Sanity check the test itself | ||
console.assert(fs.existsSync(filePath), `${filePath} does not exist`); | ||
await expect(checkFile(filePath)).rejects.toThrow( | ||
"<path> contains an unsafe attribute: 'onload'" | ||
); | ||
}); | ||
}); |
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,3 @@ | ||
<!-- Must be mention in the adjacent index.html file --> | ||
<img src="script.svg" /> | ||
<img src="onhandler.svg" /> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.