From 0ef76b8860f3972c07f3ef17b9efa26414225961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Mon, 29 Nov 2021 11:57:56 +0100 Subject: [PATCH] Fixed AS - direct editation - long integer values --- CHANGELOG.md | 5 +++-- libsrc/ffdec_lib/lexers/actionscript3_script.flex | 11 +++++++++-- libsrc/ffdec_lib/lexers/actionscript_script.flex | 11 +++++++++-- .../abc/avm2/parser/script/ActionScriptLexer.java | 9 +++++++-- .../flash/action/parser/script/ActionScriptLexer.java | 9 +++++++-- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c373462fb..9050ed66a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,13 +48,14 @@ All notable changes to this project will be documented in this file. - AS1/2 - deobfuscate object literal names - AS1/2 - spacing in with statement - Playercontrols frame display incorrect frame -- AS1/2 - empty parenthesis nullpointer +- AS1/2 - direct editation - empty parenthesis nullpointer - AS1/2 - delete on nonmember -- AS1/2 - Infinity, NaN can be used as identifiers, are normal variables +- AS1/2 - direct editation - Infinity, NaN can be used as identifiers, are normal variables - AS2 - obfuscated class attribute names - AS1/2 - newobject deobfuscated name - AS2 - obfuscated extends, implements - AS1/2 - chained assignments with obfuscated/slash variables +- AS - direct editation - long integer values ## [14.6.0] - 2021-11-22 ### Added diff --git a/libsrc/ffdec_lib/lexers/actionscript3_script.flex b/libsrc/ffdec_lib/lexers/actionscript3_script.flex index 210ab56dd..ea26a7329 100644 --- a/libsrc/ffdec_lib/lexers/actionscript3_script.flex +++ b/libsrc/ffdec_lib/lexers/actionscript3_script.flex @@ -353,13 +353,20 @@ RegExp = \/([^\r\n/]|\\\/)+\/[a-z]* /* numeric literals */ - {DecIntegerLiteral} { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong((yytext()))); } + {DecIntegerLiteral} { + try{ + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext())); + } catch(NumberFormatException nfe){ + //its too long for a Long var + return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext())); + } + } {HexIntegerLiteral} { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext().substring(2), 16)); } {OctIntegerLiteral} { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext(), 8)); } - {DoubleLiteral} { return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble((yytext()))); } + {DoubleLiteral} { return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext())); } /* comments */ {Comment} { yyline += count(yytext(),"\n"); } diff --git a/libsrc/ffdec_lib/lexers/actionscript_script.flex b/libsrc/ffdec_lib/lexers/actionscript_script.flex index 070e94e4f..77b6ff593 100644 --- a/libsrc/ffdec_lib/lexers/actionscript_script.flex +++ b/libsrc/ffdec_lib/lexers/actionscript_script.flex @@ -358,13 +358,20 @@ Preprocessor = \u00A7\u00A7 {Identifier} /* numeric literals */ - {DecIntegerLiteral} { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong((yytext()))); } + {DecIntegerLiteral} { + try{ + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext())); + } catch(NumberFormatException nfe){ + //its too long for a Long var + return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext())); + } + } {HexIntegerLiteral} { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext().substring(2), 16)); } {OctIntegerLiteral} { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext(), 8)); } - {DoubleLiteral} { return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble((yytext()))); } + {DoubleLiteral} { return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext())); } /* comments */ {Comment} { yyline += count(yytext(),"\n"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java index ccb16aa88..260b9b8f4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java @@ -1403,7 +1403,12 @@ public final class ActionScriptLexer { } case 192: break; case 13: - { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong((yytext()))); + { try{ + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext())); + } catch(NumberFormatException nfe){ + //its too long for a Long var + return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext())); + } } case 193: break; case 14: @@ -1597,7 +1602,7 @@ public final class ActionScriptLexer { } case 232: break; case 53: - { return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble((yytext()))); + { return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext())); } case 233: break; case 54: diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java index 503ad556b..244dbd1ec 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java @@ -1645,7 +1645,12 @@ public final class ActionScriptLexer { } case 185: break; case 8: - { return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong((yytext()))); + { try{ + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, Long.parseLong(yytext())); + } catch(NumberFormatException nfe){ + //its too long for a Long var + return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext())); + } } case 186: break; case 9: @@ -1789,7 +1794,7 @@ public final class ActionScriptLexer { } case 219: break; case 42: - { return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble((yytext()))); + { return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, Double.parseDouble(yytext())); } case 220: break; case 43: