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
|
|
@ -7,12 +7,13 @@ const assert = require('node:assert/strict');
|
|||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { load } = require('./harness');
|
||||
const { lit } = require('../scripts/lib/js-literal');
|
||||
|
||||
const SAVE = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8');
|
||||
|
||||
test('only Firefox on Android gets the land as a software canvas', () => {
|
||||
const { ev } = load({ seed: 777 });
|
||||
const soft = (ua) => ev(`softCanvas(${JSON.stringify(ua)})`);
|
||||
const soft = (ua) => ev(`softCanvas(${lit(ua)})`);
|
||||
// Firefox on Android, phone and tablet.
|
||||
assert.equal(soft('Mozilla/5.0 (Android 14; Mobile; rv:132.0) Gecko/132.0 Firefox/132.0'), true);
|
||||
assert.equal(soft('Mozilla/5.0 (Android 13; Tablet; rv:128.0) Gecko/128.0 Firefox/128.0'), true);
|
||||
|
|
@ -26,7 +27,7 @@ test('only Firefox on Android gets the land as a software canvas', () => {
|
|||
|
||||
test('elsewhere the land picture is an ordinary canvas, which the browser may keep on the graphics card', () => {
|
||||
const { ev, errors } = load({ seed: 777 });
|
||||
ev(`S=migrate(JSON.parse(${JSON.stringify(SAVE)}));UI.started=true;UI.pitched=true;UI.speed=0;closeModal();compute();mapGl(false,false);
|
||||
ev(`S=migrate(JSON.parse(${lit(SAVE)}));UI.started=true;UI.pitched=true;UI.speed=0;closeModal();compute();mapGl(false,false);
|
||||
window.__opts=[];const gc=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(t,o){__opts.push(o||null);return gc.call(this,t,o);};
|
||||
WL.cv=null;WL.key=null;cam.z=1.6;worldLayer(cam.z);`);
|
||||
assert.equal(ev('SOFT_CANVAS'), false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue