Move every inline <script> block and on*= attribute out of the templates into per-page files under static/js/, then tighten the CSP to script-src 'self' so injected inline scripts are actually blocked. - static/js/base.js: QR modal, form[data-confirm] submit confirmation, and a shared glimmerCopy clipboard helper (loaded by base.html) - One script per template: index, bin_view, bin_token, admin, admin_edit, admin_bin, admin_bin_edit, admin_uploads - Template data now flows through data-* attributes (data-slug, data-filename, data-max-mb, ...) instead of being interpolated into JS; confirm() prompts use data-confirm - style-src keeps unsafe-inline for the style="" attributes - Update CLAUDE.md / AGENTS.md with the no-inline-JS rule Verified in a live browser session: shorten flow, login, QR modal, paste editor (token radios, name preview), paste cards (preview dialog, expand/close), public paste view, token prompt redirect, and uploads page - no console errors or CSP violations. Co-Authored-By: Claude Fable 5 <[email protected]>
44 lines
1.5 KiB
HTML
44 lines
1.5 KiB
HTML
{{define "title"}}{{if .Paste}}{{with .Paste}}{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}}{{end}}{{else}}Paste{{end}} — Glimmer{{end}}
|
|
{{define "content"}}
|
|
{{with .Paste}}
|
|
<div style="max-width: 900px; margin: 0 auto;">
|
|
|
|
<div class="paste-header">
|
|
<div>
|
|
<h2>{{if .Title}}{{.Title}}{{else}}{{.Name}}{{end}}</h2>
|
|
<div class="paste-meta">
|
|
<code>/bin/{{.Name}}</code>
|
|
<span class="tag-pill badge-format">{{.Format}}</span>
|
|
{{if .Token}}
|
|
<span class="tag-pill badge-token">🔒 token protected</span>
|
|
{{else}}
|
|
<span class="tag-pill badge-public">public</span>
|
|
{{end}}
|
|
<span class="text-muted">updated {{.UpdatedAt.Format "2006-01-02 15:04"}}</span>
|
|
</div>
|
|
</div>
|
|
<div class="paste-toolbar">
|
|
<a href="?raw=1" class="btn btn-secondary btn-sm">Raw</a>
|
|
<button id="copy-paste-btn" class="btn btn-primary btn-sm">Copy</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card" style="padding: 2rem;">
|
|
<div class="paste-body">
|
|
{{$.PasteBody}}
|
|
</div>
|
|
</div>
|
|
|
|
<pre id="paste-raw" style="display:none">{{.Content}}</pre>
|
|
|
|
</div>
|
|
|
|
<script src="/static/js/bin_view.js"></script>
|
|
{{else}}
|
|
<div class="card center-page">
|
|
<h2>Paste not found</h2>
|
|
<p class="text-muted">This paste may have been deleted or is hidden.</p>
|
|
</div>
|
|
{{end}}
|
|
{{end}}
|