Fixed: #2515 AS1/2 Most of built-in global functions must be case in-sensitive

Fixed: AS1/2 ActionStringExtract incorrectly decompiled as String.substr instead of substring global function
This commit is contained in:
Jindra Petřík
2025-08-20 08:18:48 +02:00
parent 1c88c0304b
commit cf68684798
9 changed files with 940 additions and 1011 deletions

View File

@@ -38,7 +38,7 @@ import java.util.Objects;
public class MBStringExtractActionItem extends ActionItem {
/**
* Index
* Index - 1 based
*/
public GraphTargetItem index;
@@ -107,7 +107,7 @@ public class MBStringExtractActionItem extends ActionItem {
public static String getResult(Object count, Object index, Object value) {
String str = EcmaScript.toString(value);
int idx = EcmaScript.toInt32(index);
idx--; // index seems to be 1 based
idx--; // index is 1 based
int cnt = EcmaScript.toInt32(count);

View File

@@ -37,7 +37,7 @@ import java.util.Objects;
public class StringExtractActionItem extends ActionItem {
/**
* Index
* Index - 1 based
*/
public GraphTargetItem index;
@@ -63,10 +63,11 @@ public class StringExtractActionItem extends ActionItem {
@Override
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
value.toString(writer, localData);
writer.append(".substr");
writer.append("substring");
writer.spaceBeforeCallParenthesis(2);
writer.append("(");
value.toString(writer, localData);
writer.append(",");
index.toString(writer, localData);
writer.append(",");
count.toString(writer, localData);
@@ -98,7 +99,7 @@ public class StringExtractActionItem extends ActionItem {
public static String getResult(Object count, Object index, Object value) {
String str = EcmaScript.toString(value);
int idx = EcmaScript.toInt32(index);
idx--; // index seems to be 1 based
idx--; // index is 1 based
int cnt = EcmaScript.toInt32(count);

View File

@@ -943,7 +943,7 @@ public class ActionScript2Parser {
expectedType(SymbolType.PARENT_CLOSE);
ret = new MBStringExtractActionItem(null, null, val1, index1, len1);
break;
case SUBSTR:
case SUBSTRING:
expectedType(SymbolType.PARENT_OPEN);
GraphTargetItem val2 = (expression(inFunction, inMethod, inTellTarget, true, variables, functions, false, hasEval));
expectedType(SymbolType.COMMA);

View File

@@ -343,7 +343,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
case MBCHR:
case MBLENGTH:
case MBSUBSTRING:
case SUBSTR:
case SUBSTRING:
case LENGTH:
case RANDOM:
case INT:
@@ -611,7 +611,7 @@ public class ActionScript2SimpleParser implements SimpleParser {
expectedType(errors, SymbolType.PARENT_CLOSE);
ret = true;
break;
case SUBSTR:
case SUBSTRING:
expectedType(errors, SymbolType.PARENT_OPEN);
expression(errors, inFunction, inMethod, inTellTarget, true, variables, false, hasEval);
expectedType(errors, SymbolType.COMMA);

View File

@@ -153,7 +153,7 @@ public enum SymbolType {
RANDOM(GraphTargetItem.PRECEDENCE_PRIMARY, false),
REMOVEMOVIECLIP(GraphTargetItem.PRECEDENCE_PRIMARY, false),
STARTDRAG(GraphTargetItem.PRECEDENCE_PRIMARY, false),
SUBSTR(GraphTargetItem.PRECEDENCE_PRIMARY, false),
SUBSTRING(GraphTargetItem.PRECEDENCE_PRIMARY, false),
LENGTH(GraphTargetItem.PRECEDENCE_PRIMARY, false), //string.length
INT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
TARGETPATH(GraphTargetItem.PRECEDENCE_PRIMARY, false),

View File

@@ -126,7 +126,7 @@ public class ActionGetURL extends Action {
@Override
public String toString() {
return "GetUrl \"" + Helper.escapeActionScriptString(urlString) + "\", \"" + Helper.escapeActionScriptString(targetString) + "\"";
return "GetURL \"" + Helper.escapeActionScriptString(urlString) + "\", \"" + Helper.escapeActionScriptString(targetString) + "\"";
}
@Override