From 01cd1a3a1fdbc5f7ed8f33524459de48e0a15a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Tue, 23 Nov 2021 21:10:00 +0100 Subject: [PATCH] Fixed AS1/2 - get/setProperty when propertyindex is string --- CHANGELOG.md | 1 + .../flash/action/swf4/ActionGetProperty.java | 13 ++++++++++++- .../flash/action/swf4/ActionSetProperty.java | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 690e4e6c1..db0493a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file. - AS1/2 - direct editation - use actionadd instead of add2 on swfver < 5 - AS1/2 - tellTarget when single - AS1/2 - use slash syntax in get/setvariable only in eval/set +- AS1/2 - get/setProperty when propertyindex is string ## [14.6.0] - 2021-11-22 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java index 8f880470e..f7700345d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.BaseLocalData; @@ -29,6 +30,8 @@ import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -76,7 +79,15 @@ public class ActionGetProperty extends Action { indexInt = (int) Math.round((Double) value); } else if (value instanceof Float) { indexInt = (int) Math.round((Float) value); + } else if (((DirectValueActionItem) index).isString()) { + try { + indexInt = Integer.parseInt(((DirectValueActionItem) index).toString()); + } catch (NumberFormatException nfe) { + Logger.getLogger(ActionGetProperty.class.getName()).log(Level.SEVERE, "Invalid property index: {0}", index.toString()); + } } + } else { + Logger.getLogger(ActionGetProperty.class.getName()).log(Level.SEVERE, "Invalid property index: {0}", index.getClass().getSimpleName()); } stack.push(new GetPropertyActionItem(this, lineStartAction, target, indexInt)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java index 89f2fced3..71bb73f1e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java @@ -37,6 +37,8 @@ import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -83,7 +85,15 @@ public class ActionSetProperty extends Action { indexInt = (int) Math.round((Double) ((DirectValueActionItem) index).value); } else if (((DirectValueActionItem) index).value instanceof Float) { indexInt = (int) Math.round((Float) ((DirectValueActionItem) index).value); + } else if (((DirectValueActionItem) index).isString()) { + try { + indexInt = Integer.parseInt(((DirectValueActionItem) index).toString()); + } catch (NumberFormatException nfe) { + Logger.getLogger(ActionGetProperty.class.getName()).log(Level.SEVERE, "Invalid property index: {0}", index.toString()); + } } + } else { + Logger.getLogger(ActionGetProperty.class.getName()).log(Level.SEVERE, "Invalid property index: {0}", index.getClass().getSimpleName()); } if (value.getThroughDuplicate() instanceof IncrementActionItem) { GraphTargetItem obj = ((IncrementActionItem) value).object;