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');
|
||||
|
||||
const start = "ACT.start({});S.nextFail=1e9;S.nextEvent=1e9";
|
||||
|
||||
test('find a city by its name, without accents, by country or by its exchange (#218)', () => {
|
||||
const { ev, errors } = load();
|
||||
ev(start);
|
||||
const find = q => ev(`findCities(${JSON.stringify(q)}).join()`).split(',');
|
||||
const find = q => ev(`findCities(${lit(q)}).join()`).split(',');
|
||||
assert.equal(find('amster')[0], 'ams', 'the start of a name');
|
||||
assert.equal(find('AMSTERDAM')[0], 'ams', 'any case');
|
||||
assert.equal(find('sao paulo')[0], 'sao', 'accents are optional');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue