-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: isExternal check with malformed URL + tests (#1510)
- Loading branch information
1 parent
6c13bdb
commit ff2a66f
Showing
2 changed files
with
33 additions
and
1 deletion.
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,32 @@ | ||
const docsifyInit = require('../helpers/docsify-init'); | ||
|
||
describe(`Security`, function() { | ||
const sharedOptions = { | ||
markdown: { | ||
homepage: '# Hello World', | ||
}, | ||
routes: { | ||
'test.md': '# Test Page', | ||
}, | ||
}; | ||
|
||
describe(`Cross Site Scripting (XSS)`, function() { | ||
const slashStrings = ['//', '///']; | ||
|
||
for (const slashString of slashStrings) { | ||
const hash = `#${slashString}domain.com/file.md`; | ||
|
||
test(`should not load remote content from hash (${hash})`, async () => { | ||
await docsifyInit(sharedOptions); | ||
await expect(page).toHaveText('#main', 'Hello World'); | ||
await page.evaluate(() => (location.hash = '#/test')); | ||
await expect(page).toHaveText('#main', 'Test Page'); | ||
await page.evaluate(newHash => { | ||
location.hash = newHash; | ||
}, hash); | ||
await expect(page).toHaveText('#main', 'Hello World'); | ||
expect(page.url()).toMatch(/#\/$/); | ||
}); | ||
} | ||
}); | ||
}); |
ff2a66f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: