From 553fc2eb13df9c8c925b1670e41c54ad02ff83a5 Mon Sep 17 00:00:00 2001 From: Urgau Date: Fri, 10 Oct 2025 23:43:07 +0200 Subject: [PATCH] Prevent copying links and timestamps in our GHA logs viewer --- src/gha_logs.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gha_logs.rs b/src/gha_logs.rs index ee15990fe..7790f345c 100644 --- a/src/gha_logs.rs +++ b/src/gha_logs.rs @@ -338,6 +338,15 @@ body {{ }}); }} + // 8. Add a copy handler that force plain/text copy and removes the timestamps + // from the copied selection. + const dateRegexWithSpace = /^(\d{{4}}-\d{{2}}-\d{{2}}T\d{{2}}:\d{{2}}:\d{{2}}\.\d+Z )/gm; + document.addEventListener("copy", function(e) {{ + var text = window.getSelection().toString().replace(dateRegexWithSpace, ''); + e.clipboardData.setData('text/plain', text); + e.preventDefault(); + }}); + }} catch (e) {{ console.error(e); document.body.innerText = `Something went wrong: ${{e}}\n\n{REPORT_TO}`;