Fix CodeQL code-scanning alerts
- Values pasted into eval'd or inline-script code go through lit() (scripts/lib/js-literal.js), which escapes <, >, /, U+2028 and U+2029 after JSON.stringify - build test and i18n-check read script tags with a DOM parser or a plain search, not HTML regexes - mcp.js parses the Authorization header without a backtracking regex
This commit is contained in:
parent
e7729d0a1e
commit
dd6e4f4f8a
89 changed files with 316 additions and 213 deletions
|
|
@ -1,13 +1,14 @@
|
|||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { load } = require('./harness');
|
||||
const { lit } = require('../scripts/lib/js-literal');
|
||||
|
||||
test('pick your own AS number next to the name, or leave it empty for a random one (#135)', () => {
|
||||
const { ev, errors } = load();
|
||||
assert.ok(ev("!!document.querySelector('.network-name .nmwrap #nmIn')&&!!document.querySelector('.nmwrap .reroll[data-act=randomName]')"), 'round reroll button inside the name box');
|
||||
const sug = ev("+document.getElementById('asnIn').placeholder");
|
||||
assert.ok(ev(`asnOk(${sug})`), 'the suggestion is usable');
|
||||
const set = v => ev(`(()=>{const i=document.getElementById('asnIn');i.value=${JSON.stringify(v)};i.dispatchEvent(new Event('input'));return i.value})()`);
|
||||
const set = v => ev(`(()=>{const i=document.getElementById('asnIn');i.value=${lit(v)};i.dispatchEvent(new Event('input'));return i.value})()`);
|
||||
assert.equal(set('AS 2-0-1-9-1-7'), '201917', 'only digits stay');
|
||||
ev("ACT.start({});if(UI.pendGame)ACT.pitchSkip()");
|
||||
assert.equal(ev('S.asn'), 201917);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue