From 6c292c777ad7d238138bddc1519e41ba9cafd44d Mon Sep 17 00:00:00 2001 From: Filip Ryblad Date: Fri, 13 Sep 2024 01:00:52 +0200 Subject: [PATCH] Do not save large clipboard strings in clipboard reader --- src/main/java/ninjabrainbot/io/ClipboardReader.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/ninjabrainbot/io/ClipboardReader.java b/src/main/java/ninjabrainbot/io/ClipboardReader.java index 9f351184..6b9cd354 100644 --- a/src/main/java/ninjabrainbot/io/ClipboardReader.java +++ b/src/main/java/ninjabrainbot/io/ClipboardReader.java @@ -53,8 +53,11 @@ public void run() { } String clipboardString = null; try { - if (read) - clipboardString = (String) clipboard.getData(DataFlavor.stringFlavor); + if (read) { + clipboardString = ((String) clipboard.getData(DataFlavor.stringFlavor)); + if (clipboardString.length() > 1000) + clipboardString = clipboardString.substring(0, 1000); + } } catch (UnsupportedFlavorException | IllegalStateException | IOException ignored) { } if (clipboardString != null && !lastClipboardString.equals(clipboardString)) {