Changeset c6185fa in Klonkt
- Timestamp:
- 07/24/2026 09:30:48 PM (7 weeks ago)
- Branches:
- main
- Children:
- c1f5c23
- Parents:
- fcd6964
- git-author:
- Robin <roboburr@…> (07/24/2026 09:30:36 PM)
- git-committer:
- Robin <roboburr@…> (07/24/2026 09:30:48 PM)
- Location:
- src
- Files:
-
- 2 edited
-
middleware/render.js (modified) (1 diff)
-
routes/guardian.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/middleware/render.js
rfcd6964 rc6185fa 27 27 // partials. HTML-escaped "<script" in rendered content (e.g. sanitized post bodies) won't 28 28 // match, so this only touches real tags. 29 function injectCspNonce(html, nonce) {29 export function injectCspNonce(html, nonce) { 30 30 if (!html || !nonce) return html; 31 31 return String(html).replace(/<script(?![^>]*\snonce=)/gi, () => `<script nonce="${nonce}"`); -
src/routes/guardian.js
rfcd6964 rc6185fa 17 17 import * as Guardianship from '../services/guardianship/index.js'; 18 18 import { t as i18nT, resolveLang } from '../services/i18n.js'; 19 import { injectCspNonce } from '../middleware/render.js'; 19 20 20 21 const router = express.Router(); … … 63 64 if (!site) return res.status(404).send('No site for this account.'); 64 65 const sites = db.prepare('SELECT slug, title FROM sites WHERE owner_id = ? ORDER BY id').all(req.session.user.id); 66 // This standalone PWA page is rendered directly (not through renderPage), so 67 // the CSP nonce must be injected here — otherwise strict-dynamic blocks 68 // guardian.js and the whole dashboard is dead (buttons do nothing). 65 69 res.render('pages/guardian', { 66 70 state: dashboardState(site, L), … … 69 73 t: (k, v) => i18nT(L, k, v), 70 74 cspNonce: res.locals.cspNonce, 75 }, (err, html) => { 76 if (err) { console.error('[guardian] render error', err); return res.status(500).send('Internal Server Error'); } 77 res.send(injectCspNonce(html, res.locals.cspNonce)); 71 78 }); 72 79 });
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)