A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.
JavaScript 3d-globecesiumflight-trackinggeospatialgeospatial-intelligencegisosintphotogrammetrysatellite-trackingspatial-intelligencewebglworldview
fix(tools): enforce string schema lengths by Unicode code point
Rudy Celekli2c5fb039ce1d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7acdedf6b..f7607fd02 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,8 @@the five borough cores load and `CCTV_NYC_MAX_SOURCES` changes the cap. The catalog-wide ceiling isunchanged; extra cameras share it round-robin with the other packs.+- Tool string length validation counts Unicode characters correctly, including characters outside the basic multilingual plane.+- Treat explicitly current, complete empty vessel coverage as a successful update,clearing obsolete contacts while retaining stale or incomplete snapshots.diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.mdindex c77d1d8e3..7e1970768 100644--- a/docs/CURRENT-STATE.md+++ b/docs/CURRENT-STATE.md@@ -5310,3 +5310,8 @@ datacenters, dams and the Nepal locator retain that shared credit while displayeMilitary fragments stitch by source identity. Different mapped parcels merge onlywhen their footprints touch or contain one another, never across a seam tolerance gap.+++### fix(tools): enforce string schema lengths by Unicode code point++Count code points for minLength and maxLength, preserving ASCII behavior and regular-expression validation.diff --git a/src/tools/schema.js b/src/tools/schema.jsindex 7c40c3eb5..cdb63cfc1 100644--- a/src/tools/schema.js+++ b/src/tools/schema.js@@ -106,9 +106,10 @@ export function validateValue(schema, value, path = 'arguments') {fail('must be a string');break;}- if (schema.minLength != null && value.length < schema.minLength)+ const length = [...value].length;+ if (schema.minLength != null && length < schema.minLength)fail(`must be at least ${schema.minLength} characters`);- if (schema.maxLength != null && value.length > schema.maxLength)+ if (schema.maxLength != null && length > schema.maxLength)fail(`must be at most ${schema.maxLength} characters`);if (schema.pattern !== undefined &&diff --git a/src/tools/tool-schema-codepoints.test.mjs b/src/tools/tool-schema-codepoints.test.mjsnew file mode 100644index 000000000..c379b77e9--- /dev/null+++ b/src/tools/tool-schema-codepoints.test.mjs@@ -0,0 +1,20 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { validateValue } from './schema.js';+test('tool string schemas count Unicode characters rather than UTF-16 units', () => {+ const value = '𠮷野家😀';+ assert.deepEqual(validateValue({ type: 'string', maxLength: 4 }, value), []);+ assert.equal(+ validateValue({ type: 'string', minLength: 5 }, value).length,+ 1,+ );+ assert.equal(+ validateValue({ type: 'string', maxLength: 3 }, value).length,+ 1,+ );+ assert.deepEqual(+ validateValue({ type: 'string', minLength: 4, maxLength: 4 }, 'abcd'),+ [],+ );+ assert.equal(validateValue({ type: 'string', minLength: 2 }, '𠮷').length, 1);+});