From 168fc91e93a5fa1db0c864f3d6ef07518a38cebf Mon Sep 17 00:00:00 2001 From: sinvo Date: Wed, 13 May 2026 01:40:52 +0800 Subject: [PATCH] Improve clipboard copy fallback Avoid stale page scripts and select the returned URL when browser clipboard APIs are blocked on plain HTTP access. --- publicpaste/web.py | 58 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/publicpaste/web.py b/publicpaste/web.py index 9bfe4a0..a13ba57 100644 --- a/publicpaste/web.py +++ b/publicpaste/web.py @@ -166,6 +166,8 @@ class PublicPasteHandler(BaseHTTPRequestHandler): self.send_response(HTTPStatus.OK) self.send_header("Content-Type", "text/html; charset=utf-8") self.send_header("Content-Length", str(len(body))) + self.send_header("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0") + self.send_header("Pragma", "no-cache") self.end_headers() self.wfile.write(body) @@ -174,6 +176,7 @@ class PublicPasteHandler(BaseHTTPRequestHandler): self.send_response(status) self.send_header("Content-Type", "application/json; charset=utf-8") self.send_header("Content-Length", str(len(body))) + self.send_header("Cache-Control", "no-store") self.end_headers() self.wfile.write(body) @@ -228,8 +231,9 @@ INDEX_HTML = f""" .row {{ display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; }} .status {{ min-height: 24px; color: #59636e; }} .result {{ display: none; margin-top: 18px; padding: 14px; border: 1px solid #d8dee6; border-radius: 12px; background: #f9fafb; word-break: break-all; }} + .urlbox {{ box-sizing: border-box; width: 100%; margin-top: 8px; border: 1px solid #ccd3da; border-radius: 10px; padding: 10px 12px; font: 15px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }} .error {{ color: #b42318; }} - @media (prefers-color-scheme: dark) {{ body {{ background: #111827; color: #f9fafb; }} main {{ background: #1f2937; }} p,.status {{ color: #cbd5e1; }} textarea,.result {{ background: #111827; color: #f9fafb; border-color: #374151; }} }} + @media (prefers-color-scheme: dark) {{ body {{ background: #111827; color: #f9fafb; }} main {{ background: #1f2937; }} p,.status {{ color: #cbd5e1; }} textarea,.result,.urlbox {{ background: #111827; color: #f9fafb; border-color: #374151; }} }} @@ -239,12 +243,13 @@ INDEX_HTML = f"""
- +
Provider:
URL:
+