diff --git a/bible-local/02-architecture.md b/bible-local/02-architecture.md
index f3bd969..831df1c 100644
--- a/bible-local/02-architecture.md
+++ b/bible-local/02-architecture.md
@@ -342,3 +342,11 @@ Rules:
- PN to LOT resolution uses the active local partnumber book;
- canonical persisted mapping is `lot_mappings[]`;
- QuoteForge does not use legacy BOM tables such as `qt_bom`, `qt_lot_bundles`, or `qt_lot_bundle_items`.
+
+## Browser rendering
+
+`web/static/html-escape.js` provides the shared `escapeHtml` for HTML text and
+quoted attributes. Never interpolate data into JavaScript event attributes.
+Cart and rental controls carry escaped LOT values in `data-lot` and dispatch
+through delegated listeners. Sync errors are escaped as text; toast messages use
+`textContent`. Run `node scripts/tests/html-security.cjs` for the regression check.
diff --git a/scripts/tests/html-security.cjs b/scripts/tests/html-security.cjs
new file mode 100644
index 0000000..c0484be
--- /dev/null
+++ b/scripts/tests/html-security.cjs
@@ -0,0 +1,55 @@
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const vm = require('node:vm');
+const source = fs.readFileSync('web/templates/index.html', 'utf8');
+const base = fs.readFileSync('web/templates/base.html', 'utf8');
+const nodes = {};
+const listeners = {};
+const calls = [];
+const context = vm.createContext({
+ document: {
+ getElementById: id => nodes[id] ??= {},
+ createElement: () => ({}),
+ addEventListener: (name, handler) => listeners[name] = handler,
+ },
+ setTimeout: () => {},
+ cart: [], allComponents: [], currentTab: 'cpu',
+ getTabForCategory: () => 'cpu', getDisplayPrice: () => 1,
+ qualityDotHtml: () => '', formatMoney: String, formatPriceOrNA: String,
+ removeFromCart: lot => calls.push(['remove', lot]),
+ updateMultiQuantity: (lot, value) => calls.push(['quantity', lot, value]),
+ onRentalConditionChange: (lot, value) => calls.push(['condition', lot, value]),
+ showAutocompleteEditItem: lot => calls.push(['edit', lot]),
+});
+function loadFunction(text, name) {
+ const start = text.indexOf(`function ${name}(`);
+ assert(start >= 0);
+ const end = text.indexOf('\n}', start);
+ // Functions in base.html have eight spaces of indentation.
+ const baseEnd = text.indexOf('\n }', start);
+ vm.runInContext(text.slice(start, (end < 0 ? baseEnd + 10 : end + 2)), context);
+}
+vm.runInContext(fs.readFileSync('web/static/html-escape.js', 'utf8'), context);
+loadFunction(source, 'renderMultiSelectTab');
+vm.runInContext(source.split('
+