Fixed: #2405 Incorrect saving tags after Cloning / Copy-pasting

This commit is contained in:
Jindra Petřík
2025-06-06 05:43:21 +02:00
parent debcbbd7c5
commit 39cd80ffc2
2 changed files with 9 additions and 1 deletions

View File

@@ -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);
}