Skip to content

Commit

Permalink
Revert "safeNextPathFrom(): add tests for bad content (#1003)"
Browse files Browse the repository at this point in the history
This reverts commit 0d2efaa.
  • Loading branch information
ktuite authored Sep 25, 2023
1 parent 0d2efaa commit 69261bc
Showing 1 changed file with 3 additions and 39 deletions.
42 changes: 3 additions & 39 deletions test/unit/util/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,45 +27,9 @@ describe('util/html', () => {

describe('safeNextPathFrom()', () => {
[
// odk-central-frontend
[ '/account/edit', '/#/account/edit' ], // eslint-disable-line no-multi-spaces
[ '/users', '/#/users' ], // eslint-disable-line no-multi-spaces
[ '/users"><badTag ', '/#/users%22%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces

// query params
[ '/users?"><badTag ', '/#/users?%22%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces
[ '/users?="><badTag ', '/#/users?=%22%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces
[ '/users?a="><badTag ', '/#/users?a=%22%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces
[ '/users?"=><badTag ', '/#/users?%22=%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces

// fragments
[ '/users#"><badTag ', '/#/users#%22%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces
[ '/users#="><badTag ', '/#/users#=%22%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces
[ '/users#a="><badTag ', '/#/users#a=%22%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces
[ '/users#"=><badTag ', '/#/users#%22=%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces

// query string & fragment
[ '/users?"=1#"=><badTag ', '/#/users?%22=1#%22=%3E%3CbadTag' ], // eslint-disable-line no-multi-spaces

// enketo-express
[ '/-/xyz', 'http://localhost:8989/-/xyz' ], // eslint-disable-line no-multi-spaces
[ '/-/xyz?"><b', 'http://localhost:8989/-/xyz?%22%3E%3Cb' ], // eslint-disable-line no-multi-spaces
[ '/-/xyz#"><b', 'http://localhost:8989/-/xyz#%22%3E%3Cb' ], // eslint-disable-line no-multi-spaces
[ '/-/xyz?"><b#"><b', 'http://localhost:8989/-/xyz?%22%3E%3Cb#%22%3E%3Cb' ], // eslint-disable-line no-multi-spaces

// bad domain
[ 'http://example.com', '/#/' ], // eslint-disable-line no-multi-spaces
// with @ char - not a problem if positioned in fragment or after first `/`:
[ '@baddomain.com', '/#/@baddomain.com' ], // eslint-disable-line no-multi-spaces
[ '/-/@baddomain.com', 'http://localhost:8989/-/@baddomain.com' ], // eslint-disable-line no-multi-spaces
[ '&64;baddomain.com', '/#/&64;baddomain.com' ], // eslint-disable-line no-multi-spaces
[ '/-/&64;baddomain.com', 'http://localhost:8989/-/&64;baddomain.com' ], // eslint-disable-line no-multi-spaces
[ 'http://localhost:[email protected]', '/#/' ], // eslint-disable-line no-multi-spaces
[ 'http://localhost:[email protected]', '/#/' ], // eslint-disable-line no-multi-spaces

// bad protocols
[ 'https://localhost:8989', '/#/' ], // eslint-disable-line no-multi-spaces
[ 'javascript:badFn()', '/#/' ], // eslint-disable-line no-multi-spaces,no-script-url
[ '/-/xyz', 'http://localhost:8989/-/xyz' ], // eslint-disable-line no-multi-spaces
[ '/account/edit', '/#/account/edit' ], // eslint-disable-line no-multi-spaces
[ '/users', '/#/users' ], // eslint-disable-line no-multi-spaces
].forEach(([next, expected]) => {
it(`should convert next=${next} to ${expected}`, () => {
safeNextPathFrom(next).should.equal(expected);
Expand Down

0 comments on commit 69261bc

Please sign in to comment.