Skip to content

Commit 553fc2e

Browse files
committed
Prevent copying links and timestamps in our GHA logs viewer
1 parent bed8b60 commit 553fc2e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/gha_logs.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,15 @@ body {{
338338
}});
339339
}}
340340
341+
// 8. Add a copy handler that force plain/text copy and removes the timestamps
342+
// from the copied selection.
343+
const dateRegexWithSpace = /^(\d{{4}}-\d{{2}}-\d{{2}}T\d{{2}}:\d{{2}}:\d{{2}}\.\d+Z )/gm;
344+
document.addEventListener("copy", function(e) {{
345+
var text = window.getSelection().toString().replace(dateRegexWithSpace, '');
346+
e.clipboardData.setData('text/plain', text);
347+
e.preventDefault();
348+
}});
349+
341350
}} catch (e) {{
342351
console.error(e);
343352
document.body.innerText = `Something went wrong: ${{e}}\n\n{REPORT_TO}`;

0 commit comments

Comments
 (0)