From 39cd80ffc2da3830453ab321343d392a447cbcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 6 Jun 2025 05:43:21 +0200 Subject: [PATCH] Fixed: #2405 Incorrect saving tags after Cloning / Copy-pasting --- CHANGELOG.md | 2 ++ .../src/com/jpexs/decompiler/flash/tags/Tag.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6f1e1b13..b53e9e8cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ All notable changes to this project will be documented in this file. - AS3 difference between namespace keyword and const of type Namespace - [#2462] AS3 debugger - incorrect line info injected - [#2464] SVG export - minimum stroke width of 1 px +- [#2405] Incorrect saving tags after Cloning / Copy-pasting ## [23.0.1] - 2025-05-16 ### Fixed @@ -3854,6 +3855,7 @@ Major version of SWF to XML export changed to 2. [#2461]: https://www.free-decompiler.com/flash/issues/2461 [#2462]: https://www.free-decompiler.com/flash/issues/2462 [#2464]: https://www.free-decompiler.com/flash/issues/2464 +[#2405]: https://www.free-decompiler.com/flash/issues/2405 [#2427]: https://www.free-decompiler.com/flash/issues/2427 [#1826]: https://www.free-decompiler.com/flash/issues/1826 [#2448]: https://www.free-decompiler.com/flash/issues/2448 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java index ea6be08a6..2313eadc0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/Tag.java @@ -581,9 +581,15 @@ public abstract class Tag implements NeedsCharacters, Exportable, Serializable { * @throws IOException On I/O error */ public Tag cloneTag() throws InterruptedException, IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] data = getData(); + byte[] headerData = getHeader(data.length); + baos.write(headerData); + baos.write(data); + + byte[] dataWithHeader = baos.toByteArray(); SWFInputStream tagDataStream = new SWFInputStream(swf, data, 0, data.length); - TagStub copy = new TagStub(swf, getId(), "Unresolved", new ByteArrayRange(data), tagDataStream); + TagStub copy = new TagStub(swf, getId(), "Unresolved", new ByteArrayRange(dataWithHeader), tagDataStream); copy.forceWriteAsLong = forceWriteAsLong; return SWFInputStream.resolveTag(copy, 0, false, true, false, false); }