From 74252d654eac93733ddf1c982b516f5fe0715a4f Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Fri, 10 Jul 2026 17:23:52 -0500 Subject: [PATCH] Fix version.js build-version script under the WSH JScript engine String.prototype.trim() (added in #1455 to complete the newline sanitization) is not implemented by the Windows Script Host JScript engine that runs version.js via cscript, so every Windows CI build logged 'version.js(48,3) Microsoft JScript runtime error: Object doesn't support this property or method'. Replace trim() with an ES3-compatible global-anchored regex that strips leading/trailing whitespace (including all trailing newlines), so the script runs cleanly while keeping the complete-sanitization behavior CodeQL asked for. Verified: 'cscript //nologo version.js' now exits 0 and regenerates Version.hpp; confirmed the JScript engine rejects .trim() with the same error seen in CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tools/version.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/version.js b/tools/version.js index 4f090e1be..45c4c922e 100644 --- a/tools/version.js +++ b/tools/version.js @@ -44,8 +44,11 @@ function generateVersionHpp() { // Read version tag var ver1 = readAll("..\\Solutions\\version.txt"); - // Remove end-of-line - ver1 = ver1.trim(); + // Remove leading/trailing whitespace. Use a regex rather than String.trim() so this + // runs under the Windows Script Host JScript engine (cscript), which does not + // implement String.prototype.trim(); the global anchored pattern also fully strips + // trailing newlines (the CodeQL incomplete-sanitization concern). + ver1 = ver1.replace(/^\s+|\s+$/g, ""); ver1 = updateYearAndDay(ver1); // console.log("version.txt => " + ver1 + "\n"); var ver2 = ver1.split(".").join(",");