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
|
|
@ -137,8 +137,9 @@ function createHttpServer(factory, { host, allow = [], token = null } = {}) {
|
|||
const o = validateOriginHeader(req.headers.origin, origins);
|
||||
if (!o.ok) return deny(res, 403, 'Origin not allowed: a web page may not drive this server.');
|
||||
if (token) {
|
||||
const m = /^Bearer\s+(.+)$/i.exec(req.headers.authorization || '');
|
||||
if (!m || !sameToken(m[1].trim(), token)) return deny(res, 401, 'A bearer token is required.', { 'www-authenticate': 'Bearer realm="seriesoftubes"' });
|
||||
const auth = String(req.headers.authorization || '').trim(), sp = auth.search(/\s/);
|
||||
const given = sp > 0 && auth.slice(0, sp).toLowerCase() === 'bearer' ? auth.slice(sp + 1).trim() : '';
|
||||
if (!given || !sameToken(given, token)) return deny(res, 401, 'A bearer token is required.', { 'www-authenticate': 'Bearer realm="seriesoftubes"' });
|
||||
}
|
||||
handle(req, res);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue