From a76ce37d331b99109e6bd75d8d5efa442199f9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 1 Aug 2025 18:24:56 +0200 Subject: [PATCH] Fixed: #2498 Public traits with same name were not distinguishable --- CHANGELOG.md | 2 ++ .../flash/abc/avm2/model/FullMultinameAVM2Item.java | 2 +- .../abc/usages/multinames/ClassNameMultinameUsage.java | 2 +- .../abc/usages/multinames/ConstVarNameMultinameUsage.java | 2 +- .../abc/usages/multinames/MethodNameMultinameUsage.java | 2 +- .../flash/abc/usages/multinames/MultinameUsage.java | 7 ++++--- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 924e7c931..f29667d1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ All notable changes to this project will be documented in this file. - SymbolClass export/import did not support obfuscated names - Configuration TOML file encoding (UTF-8) - [#2496] Fonts - adding characters - truncating too wide advance widths +- [#2498] Public traits with same name were not distinguishable ### Changed - Icon of "Deobfuscation options" menu from pile of pills to medkit @@ -3956,6 +3957,7 @@ Major version of SWF to XML export changed to 2. [#1295]: https://www.free-decompiler.com/flash/issues/1295 [#116]: https://www.free-decompiler.com/flash/issues/116 [#2496]: https://www.free-decompiler.com/flash/issues/2496 +[#2498]: https://www.free-decompiler.com/flash/issues/2498 [#2476]: https://www.free-decompiler.com/flash/issues/2476 [#2404]: https://www.free-decompiler.com/flash/issues/2404 [#1418]: https://www.free-decompiler.com/flash/issues/1418 diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java index c514c26be..66de3d6e2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java @@ -212,7 +212,7 @@ public class FullMultinameAVM2Item extends AVM2Item { writer.append("*"); } else { Reference customNsRef = new Reference<>(null); - String localName = constants.getMultiname(multinameIndex).getNameAndCustomNamespace(localData.usedDeobfuscations, localData.abc, localData.fullyQualifiedNames, false, true, customNsRef); + String localName = constants.getMultiname(multinameIndex).getNameAndCustomNamespace(localData.usedDeobfuscations, localData.abc, fullyQualifiedNames, false, true, customNsRef); DottedChain customNs = customNsRef.getVal(); if (customNs != null) { String nsname = customNs.getLast(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ClassNameMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ClassNameMultinameUsage.java index d52a60794..391693415 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ClassNameMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ClassNameMultinameUsage.java @@ -89,7 +89,7 @@ public class ClassNameMultinameUsage extends MultinameUsage implements Definitio } } if (other instanceof ClassNameMultinameUsage) { - return sameMultinameName(other); + return sameMultinameName(other, true); } return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ConstVarNameMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ConstVarNameMultinameUsage.java index 42fe51984..dc1441993 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ConstVarNameMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/ConstVarNameMultinameUsage.java @@ -51,7 +51,7 @@ public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage implement if ((other instanceof ConstVarNameMultinameUsage) || (other instanceof MethodNameMultinameUsage)) { TraitMultinameUsage otherTrait = (TraitMultinameUsage) other; if (otherTrait.classIndex == classIndex && otherTrait.traitsType == traitsType && otherTrait.parentTraitIndex == parentTraitIndex) { - if (other.sameMultinameName(this)) { + if (other.sameMultinameName(this, false)) { return true; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MethodNameMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MethodNameMultinameUsage.java index 2e2898f46..f56e5b6ed 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MethodNameMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MethodNameMultinameUsage.java @@ -52,7 +52,7 @@ public class MethodNameMultinameUsage extends MethodMultinameUsage implements De if ((other instanceof MethodNameMultinameUsage) || (other instanceof ConstVarNameMultinameUsage)) { TraitMultinameUsage otherTrait = (TraitMultinameUsage) other; if (otherTrait.classIndex == classIndex && otherTrait.traitsType == traitsType && otherTrait.parentTraitIndex == parentTraitIndex) { - if (other.sameMultinameName(this)) { + if (other.sameMultinameName(this, false)) { if (other instanceof MethodNameMultinameUsage) { MethodNameMultinameUsage otherM = (MethodNameMultinameUsage) other; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MultinameUsage.java index bd0248493..b91c0c0fe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/multinames/MultinameUsage.java @@ -75,9 +75,10 @@ public abstract class MultinameUsage implements Usage { /** * Checks if this multiname name is the same as other multiname name. * @param other Other multiname usage + * @param includePublic Include public namespaces? * @return True if names are the same */ - protected boolean sameMultinameName(MultinameUsage other) { + protected boolean sameMultinameName(MultinameUsage other, boolean includePublic) { Multiname thisM = abc.constants.getMultiname(multinameIndex); Multiname otherM = other.abc.constants.getMultiname(other.multinameIndex); if (thisM == null && otherM == null) { @@ -106,8 +107,8 @@ public abstract class MultinameUsage implements Usage { } //public or package internal are colliding when have same package ns - if ((thisNs.kind == Namespace.KIND_PACKAGE || thisNs.kind == Namespace.KIND_PACKAGE_INTERNAL) - && (otherNs.kind == Namespace.KIND_PACKAGE || otherNs.kind == Namespace.KIND_PACKAGE_INTERNAL)) { + if (includePublic && ((thisNs.kind == Namespace.KIND_PACKAGE || thisNs.kind == Namespace.KIND_PACKAGE_INTERNAL) + && (otherNs.kind == Namespace.KIND_PACKAGE || otherNs.kind == Namespace.KIND_PACKAGE_INTERNAL))) { return Objects.equals(thisNs.getName(abc.constants), otherNs.getName(other.abc.constants)); }