[object Object]

← back to Selfadhesivewallpaper

tighten static bak/pre guard to anchored suffix regex

82e76908b1817668df0975dbda491d2490142a3c · 2026-05-19 07:54:05 -0700 · Steve Abrams

Drop the broad /\.(bak|pre-)/ test that could match any path
containing .pre- mid-string; anchored suffix match is sufficient.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 82e76908b1817668df0975dbda491d2490142a3c
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue May 19 07:54:05 2026 -0700

    tighten static bak/pre guard to anchored suffix regex
    
    Drop the broad /\.(bak|pre-)/ test that could match any path
    containing .pre- mid-string; anchored suffix match is sufficient.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
 server.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server.js b/server.js
index c7ca2f3..edcfd05 100644
--- a/server.js
+++ b/server.js
@@ -84,7 +84,7 @@ app.locals.siteConfig = cfg;
 
 // Guard: never serve snapshot/backup files from the static root.
 app.use((req, res, next) => {
-  if (/\.(bak|pre-[^/]*)(\.[^/]*)?$/i.test(req.path) || /\.(bak|pre-)/i.test(req.path)) {
+  if (/\.bak(\.[^/]*)?$/i.test(req.path) || /\.pre-[^/]*$/i.test(req.path)) {
     return res.status(404).send('Not found');
   }
   next();

← c3533c4 untrack snapshot backups + broaden .gitignore  ·  back to Selfadhesivewallpaper  ·  add noreferrer to external Facebook target=_blank link 41fb0f1 →