← back to Big Red
guard .bak/.pre-/.orig/.swp paths from static + broaden .gitignore
a2d0c5a4e783c166706808e9b0ce6b7b85b786f1 · 2026-05-19 17:24:48 -0700 · Steve Abrams
404 any request whose path matches editor/snapshot backup suffixes before
the express.static handler can serve them. Also broaden .gitignore so
those files never get tracked in the first place. Mechanical safety pass
— no chat, persona, or vendor-scrub code touched.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Files touched
Diff
commit a2d0c5a4e783c166706808e9b0ce6b7b85b786f1
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Tue May 19 17:24:48 2026 -0700
guard .bak/.pre-/.orig/.swp paths from static + broaden .gitignore
404 any request whose path matches editor/snapshot backup suffixes before
the express.static handler can serve them. Also broaden .gitignore so
those files never get tracked in the first place. Mechanical safety pass
— no chat, persona, or vendor-scrub code touched.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
.gitignore | 8 ++++++++
server.js | 9 +++++++++
2 files changed, 17 insertions(+)
diff --git a/.gitignore b/.gitignore
index 4a0b3ea..2391fb5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,11 @@ tmp/
dist/
build/
.next/
+# editor/snapshot backups — never tracked
+*.bak
+*.bak.*
+*.pre-*
+*.orig
+*.swp
+*.swo
+*.tmp
diff --git a/server.js b/server.js
index 770e759..4729186 100644
--- a/server.js
+++ b/server.js
@@ -287,6 +287,15 @@ function detectLanHost() {
const app = express();
app.use(express.json({ limit: '20mb' }));
app.get('/phone', (req, res) => res.sendFile(path.join(__dirname, 'public', 'phone.html')));
+// 404-guard: never serve editor/snapshot backup files even if they leak into public/
+app.use((req, res, next) => {
+ if (/\.(bak|pre-[\w.-]+|orig|swp|swo|tmp)(\?|$|\/)/i.test(req.path) ||
+ /\.bak\.[\w.-]+(\?|$|\/)/i.test(req.path) ||
+ /\.pre-[\w.-]+(\?|$|\/)/i.test(req.path)) {
+ return res.status(404).end();
+ }
+ next();
+});
app.use(express.static(path.join(__dirname, 'public')));
const upload = multer({ storage: multer.memoryStorage(), limits: { fileSize: 25 * 1024 * 1024 } });
← ed84c03 aichat: pm2 ecosystem entry — Big Red managed as 'aichat' on
·
back to Big Red
·
fix: resolve claude CLI to absolute path at startup + extend ca5e47a →