← back to Selfadhesivewallpaper
step2 vendor-leak fix: dual-key /sample resolver + handle_display hrefs
b84bd8246c24f3d72197acd2464bdbc6c5500fe8 · 2026-06-09 13:47:41 -0700 · Steve
Files touched
M public/index.htmlM server.js
Diff
commit b84bd8246c24f3d72197acd2464bdbc6c5500fe8
Author: Steve <steve@designerwallcoverings.com>
Date: Tue Jun 9 13:47:41 2026 -0700
step2 vendor-leak fix: dual-key /sample resolver + handle_display hrefs
---
public/index.html | 10 +++++-----
server.js | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/public/index.html b/public/index.html
index abcdbaf..f3ca42f 100644
--- a/public/index.html
+++ b/public/index.html
@@ -592,9 +592,9 @@ function cardHTML(p) {
return '<img loading="' + (eager ? 'eager' : 'lazy') + '"' + (eager ? ' fetchpriority="high"' : '') + ' src="' + escAttr(safeImg(p.image_url)) + '" alt="' + escAttr(p.title) + '">'
+ '<div class="overlay">'
+ '<div class="pat">' + escAttr(p.pattern_name || p.title) + '</div>'
- + '<div class="ven">Designer Wallcoverings · ' + escAttr(p.sku || p.handle || '') + '</div>'
+ + '<div class="ven">Designer Wallcoverings · ' + escAttr(p.sku || p.handle_display || p.handle || '') + '</div>'
+ '<div class="actions">'
- + '<button class="sample-btn" onclick="event.stopPropagation();dwmOpen(\'Sample\',' + JSON.stringify({sku:p.sku||p.handle, title:p.title, image_url:safeImg(p.image_url)}).replace(/"/g,'"') + ')">Sample</button>'
+ + '<button class="sample-btn" onclick="event.stopPropagation();dwmOpen(\'Sample\',' + JSON.stringify({sku:p.sku||p.handle_display||p.handle, title:p.title, image_url:safeImg(p.image_url)}).replace(/"/g,'"') + ')">Sample</button>'
+ '</div></div>';
}
@@ -606,7 +606,7 @@ function rowHTML(p) {
const aes = LABELS[p.aesthetic] || p.aesthetic || '—';
return '<img loading="lazy" src="' + escAttr(safeImg(p.image_url)) + '" alt="' + escAttr(p.title) + '">'
+ '<div class="r-pat">' + escAttr(p.pattern_name || p.title) + '</div>'
- + '<div class="r-col r-sku">' + escAttr(p.sku || p.handle || '—') + '</div>'
+ + '<div class="r-col r-sku">' + escAttr(p.sku || p.handle_display || p.handle || '—') + '</div>'
+ '<div class="r-col r-aes">' + escAttr(String(aes).replace(/-/g, ' ')) + '</div>'
+ '<div class="r-col r-price">' + price + '</div>';
}
@@ -616,7 +616,7 @@ function rowHTML(p) {
// chips, and CTAs for sample + Big Red chat. The modal NEVER reveals vendor.
function openDetails(p) {
const safeP = {
- sku: p.sku || p.handle || '',
+ sku: p.sku || p.handle_display || p.handle || '',
title: p.title || '',
pattern: p.pattern_name || p.title || '',
image_url: safeImg(p.image_url),
@@ -1240,7 +1240,7 @@ renderRailSections();
const curated = items.filter((_, i) => i % 5 === 3).slice(0, 12);
function card(p) {
const url = (p.image_url || '').replace(/(_\d+x\d*)(\.(jpg|jpeg|png|webp|gif))(\?|$)/i, '$2$4');
- return '<a class="rail-card" href="/sample/' + encodeURIComponent(p.handle || p.sku) + '">' +
+ return '<a class="rail-card" href="/sample/' + encodeURIComponent(p.handle_display || p.handle || p.sku) + '">' +
'<img src="' + url + '" alt="' + (p.title || '').replace(/"/g, '"') + '" loading="lazy">' +
'<div class="rc-title">' + ((p.title || '').split('|')[0] || '').trim() + '</div>' +
'<div class="rc-meta">Designer Wallcoverings</div>' +
diff --git a/server.js b/server.js
index eced8f8..dc77ea3 100644
--- a/server.js
+++ b/server.js
@@ -186,8 +186,40 @@ app.get('/api/facets', (req, res) => {
app.get('/api/health', (req, res) => res.json({ status: 'ok', count: PRODUCTS_NICHE.length, dropped: DROPPED }));
+// Step 2 of the vendor handle/sku text-leak fix (2026-06-09): the client's
+// /sample/ hrefs now point at the vendor-scrubbed `handle_display` slug
+// (emitted by _shared/api-vendor-redact since Step 1), so the raw vendor-bearing
+// handle never rides in the URL bar. This route is DUAL-KEY — it resolves the raw
+// handle/sku FIRST (old bookmarks + buy path, byte-identical behavior), then falls
+// back to a redacted->product map built after catalog load. If two raw handles
+// redact to the same display slug, that slug is logged and left raw-only.
+const { redactVendorText } = require('../_shared/vendor-text-redact');
+let SAMPLE_DISPLAY = new Map(); // redacted display slug -> product
+function buildSampleDisplayMap() {
+ const map = new Map();
+ const collided = new Set();
+ for (const p of PRODUCTS_NICHE) {
+ for (const key of [p.handle, p.sku]) {
+ if (!key) continue;
+ const d = redactVendorText(String(key));
+ if (!d || d === key) continue; // nothing redacted — raw route already matches
+ const prev = map.get(d);
+ if (prev && prev !== p) { collided.add(d); continue; }
+ map.set(d, p);
+ }
+ }
+ for (const d of collided) {
+ map.delete(d);
+ console.warn(`[selfadhesivewallpaper] /sample display-slug collision — keeping raw-only for "${d}"`);
+ }
+ SAMPLE_DISPLAY = map;
+ console.log(`[selfadhesivewallpaper] /sample dual-key map: ${map.size} display slugs, ${collided.size} collisions (raw-only)`);
+}
+
app.get('/sample/:handle', (req, res) => {
- const p = PRODUCTS_NICHE.find(x => x.handle === req.params.handle || x.sku === req.params.handle);
+ const key = req.params.handle;
+ const p = PRODUCTS_NICHE.find(x => x.handle === key || x.sku === key) // raw first — old behavior intact
+ || SAMPLE_DISPLAY.get(key); // then the redacted display form
if (!p) return res.status(404).send('Not found');
res.redirect(302, p.product_url || `${DW_SHOPIFY}/products/${encodeURIComponent(p.handle)}#sample`);
});
@@ -234,6 +266,7 @@ if (catalog) catalog.mount(app, { siteSlug: SITE_SLUG, rails: SITE_RAILS });
}
PRODUCTS_NICHE = PRODUCTS.filter(nicheFit);
console.log(`[${__SITE}] niche filter: kept ${PRODUCTS_NICHE.length} of ${PRODUCTS.length}`);
+ buildSampleDisplayMap(); // Step 2: redacted->raw /sample resolver keys
app.listen(PORT, '127.0.0.1', () => {
console.log(`selfadhesivewallpaper listening on http://127.0.0.1:${PORT}`);
});
← 8f29ef9 Scrub residual vendor names from products.json (title/vendor
·
back to Selfadhesivewallpaper
·
fix: safeImg allow same-origin /img/ proxy urls (vendor-neut d2ea5ac →