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 7cf6872b..e9b0c33c 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,7 @@ jQuery.PrivateBin = (function($) { }; if (attachmentsData.length) { cipherMessage['attachment'] = attachmentsData; - cipherMessage['attachment_name'] = AttachmentViewer.getFiles().map((fileInfo => fileInfo.name)); + 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==',