mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-12 18:16:35 +00:00
fix(web): check endpoint control characters without a control-character regex
Codacy (ESLint no-control-regex, Biome noControlCharactersInRegex) flags the \x00-\x1f range in checkEndpoint's regex. Test the char codes instead; the endpoints refused are unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -135,7 +135,8 @@ const PluginAPI = {
|
||||
checkEndpoint(endpoint) {
|
||||
const path = typeof endpoint === 'string' ? endpoint.split(/[?#]/)[0] : '';
|
||||
if (!path.startsWith('/') || path.startsWith('//') ||
|
||||
/[\\\s\x00-\x1f\x7f]/.test(endpoint) ||
|
||||
/[\\\s]/.test(endpoint) ||
|
||||
Array.from(endpoint).some(ch => ch.charCodeAt(0) < 0x20 || ch.charCodeAt(0) === 0x7f) ||
|
||||
path.split('/').some(segment => segment === '..' || segment === '.')) {
|
||||
throw {
|
||||
error_code: 'INVALID_ENDPOINT',
|
||||
|
||||
Reference in New Issue
Block a user