From 8a7f7a60a5c2e7eaabec53ff54d730625ab26592 Mon Sep 17 00:00:00 2001 From: gittihub-jpg Date: Tue, 28 Apr 2026 12:09:41 +0200 Subject: [PATCH 1/3] fix: Bugs in the attachment functionality (#1824) Fixes #1824 Generated by OpenClaw bounty agent. Signed-off-by: gittihub-jpg --- js/privatebin.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 7cf6872b..a03a5111 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -3157,6 +3157,11 @@ jQuery.PrivateBin = (function($) { if (!$attachment.length) { return false; } + // Check if there are actual attachment data items (not just UI elements) + if (attachmentsData.length > 0) { + return true; + } + // Also check UI elements in case data was removed but UI wasn't updated return [...$attachment.children()].length > 0; }; @@ -3170,10 +3175,8 @@ jQuery.PrivateBin = (function($) { */ me.hasAttachmentData = function() { - if ($attachment.length) { - return true; - } - return false; + // Check if there are actual attachment data items (not just UI elements) + return attachmentsData.length > 0; }; /** @@ -5181,7 +5184,7 @@ jQuery.PrivateBin = (function($) { const plainText = Editor.getText(), format = PasteViewer.getFormat(), // the methods may return different values if no files are attached (null, undefined or false) - files = TopNav.getFileList() || AttachmentViewer.getFiles() || AttachmentViewer.hasAttachment(); + files = TopNav.getFileList() || AttachmentViewer.getFiles() || AttachmentViewer.hasAttachmentData(); // do not send if there is no data if (plainText.length === 0 && !files) { @@ -5227,7 +5230,10 @@ jQuery.PrivateBin = (function($) { }; if (attachmentsData.length) { cipherMessage['attachment'] = attachmentsData; - cipherMessage['attachment_name'] = AttachmentViewer.getFiles().map((fileInfo => fileInfo.name)); + const fileNames = AttachmentViewer.getFiles(); + if (fileNames && Array.isArray(fileNames)) { + cipherMessage['attachment_name'] = fileNames.map((fileInfo => fileInfo.name)); + } } else if (AttachmentViewer.hasAttachment()) { // fall back to cloned part let attachments = AttachmentViewer.getAttachments(); From 88b7cd8e96b69d4f4898afe959e50871bdcaa445 Mon Sep 17 00:00:00 2001 From: gittihub-jpg Date: Wed, 29 Apr 2026 10:04:22 +0200 Subject: [PATCH 2/3] Update js/privatebin.js Thanks, updated this to avoid relying on `Array.isArray()` for the `FileList` case and to always set `attachment_name` to an array. Co-authored-by: Mikhail Romanov <42250412+Ribas160@users.noreply.github.com> --- js/privatebin.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index a03a5111..7a2932cd 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -5230,9 +5230,7 @@ jQuery.PrivateBin = (function($) { }; if (attachmentsData.length) { cipherMessage['attachment'] = attachmentsData; - const fileNames = AttachmentViewer.getFiles(); - if (fileNames && Array.isArray(fileNames)) { - cipherMessage['attachment_name'] = fileNames.map((fileInfo => fileInfo.name)); + cipherMessage['attachment_name'] = AttachmentViewer.getFiles()?.map((fileInfo => fileInfo.name)) ?? []; } } else if (AttachmentViewer.hasAttachment()) { // fall back to cloned part From ebadfe43ec707aa6a00e9338ad23196af4a3d4a7 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 29 Apr 2026 22:07:50 +0200 Subject: [PATCH 3/3] chore: fix typo, update SRI hash and docs --- CHANGELOG.md | 1 + js/privatebin.js | 1 - lib/Configuration.php | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fdc1d04..5f1afb07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * FIXED: Some exceptions not getting translated * FIXED: Attachment disappears after a "paste" in the message area (#1731) * FIXED: The content format is not reset when creating a new document (#1707) +* FIXED: State corruption after removing attachment (#1824) ## 1.7.9 (2025-11-13) * CHANGED: Upgrading libraries to: base-x 5.0.1, bootstrap 5.3.8, DOMpurify 3.2.7, ip-lib 1.21.0 & kjua 0.10.0 diff --git a/js/privatebin.js b/js/privatebin.js index 7a2932cd..e9b0c33c 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -5231,7 +5231,6 @@ jQuery.PrivateBin = (function($) { if (attachmentsData.length) { cipherMessage['attachment'] = attachmentsData; cipherMessage['attachment_name'] = AttachmentViewer.getFiles()?.map((fileInfo => fileInfo.name)) ?? []; - } } else if (AttachmentViewer.hasAttachment()) { // fall back to cloned part let attachments = AttachmentViewer.getAttachments(); diff --git a/lib/Configuration.php b/lib/Configuration.php index 744dd90d..27f5506b 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -122,7 +122,7 @@ class Configuration 'js/kjua-0.10.0.js' => 'sha512-BYj4xggowR7QD150VLSTRlzH62YPfhpIM+b/1EUEr7RQpdWAGKulxWnOvjFx1FUlba4m6ihpNYuQab51H6XlYg==', 'js/legacy.js' => 'sha512-RQEo1hxpNc37i+jz/D9/JiAZhG8GFx3+SNxjYnI7jUgirDIqrCSj6QPAAZeaidditcWzsJ3jxfEj5lVm7ZwTRQ==', 'js/prettify.js' => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==', - 'js/privatebin.js' => 'sha512-6SwOJniNN8RBmAK7yCt4ly2qYyH8OALxB74/K1AJgw+YnZgRCfTDVq1qY1K5Y2QCxCODGGTpAjTqQRExzCqV7g==', + 'js/privatebin.js' => 'sha512-p9zI8Ybt1CGqZ6NIHCQlxLg0nED6FpemmcSCZsUBsS4JXRWlV8lYv9NrdvS0Gxad0DPRNjOwvsN+n7o2E9BmAg==', 'js/purify-3.4.1.js' => 'sha512-280a/Vb6fVFsYaeRrkuDp4EDmdYlt2XS+dlDEO/U9qljPrAraA2bIzHTNmP+9dpwPDDwTML+RS+h5iaagPwTzA==', 'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==', 'js/zlib-1.3.2.js' => 'sha512-RAhJgxg9siMIA8ky4c10Rc2zUgnK80olHB8Tt1IOYWY4Eh1WmrviQkDn+sgBlb38ZHq3tzufGC41kP360gmosQ==',