diff --git a/lib/jsyntaxpane-0.9.5.jar b/lib/jsyntaxpane-0.9.5.jar index 5db5a1b5c..d1549edd4 100644 Binary files a/lib/jsyntaxpane-0.9.5.jar and b/lib/jsyntaxpane-0.9.5.jar differ diff --git a/libsrc/ffdec_lib/lexers/text.flex b/libsrc/ffdec_lib/lexers/text.flex index ad655f36f..578ad3cdb 100644 --- a/libsrc/ffdec_lib/lexers/text.flex +++ b/libsrc/ffdec_lib/lexers/text.flex @@ -37,7 +37,7 @@ package com.jpexs.decompiler.flash.tags.text; private StringBuilder string = null; private int repeatNum = 1; - + /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader @@ -64,7 +64,7 @@ StringCharacter = [^\r\n\"\\] OIdentifierCharacter = [^\r\n\u00A7\\] DecIntegerLiteral = (0 | [1-9][0-9]*) [ui]? LineTerminator = \r|\n|\r\n - +PositiveNumberLiteral = 0 | [1-9][0-9]* %state PARAMETER,VALUE,OIDENTIFIER,STRING @@ -171,31 +171,34 @@ LineTerminator = \r|\n|\r\n { \" { yybegin(VALUE); + repeatNum = 1; // length also includes the trailing quote String tos = string.toString(); string = null; return new ParsedSymbol(SymbolType.PARAMETER_VALUE, tos); } - {StringCharacter}+ { string.append(yytext()); } + {StringCharacter} { for(int r=0;r map = swf.getAs3ObfuscatedIdentifiers(); + if (Configuration.useSafeStr.get() && as3) { + + Map map = swf == null ? new LinkedHashMap<>() : swf.getAs3ObfuscatedIdentifiers(); if (map.containsKey(s)) { used.add(s); return map.get(s); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index b837e9831..e26bd9864 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -65,6 +65,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFType; import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.ByteArrayRange; +import com.jpexs.helpers.Helper; import com.jpexs.helpers.SerializableImage; import java.awt.Color; import java.awt.Font; @@ -898,7 +899,8 @@ public class DefineEditTextTag extends TextTag { writer.append("leading ").append(leading).newLine(); } if (!variableName.isEmpty()) { - writer.append("variablename ").append(DottedChain.parseNoSuffix(variableName).toPrintableString(new LinkedHashSet<>(), getSwf(), false)).newLine(); + writer.append("variablename ").append("\"").append(Helper.escapePCodeString(variableName)).append("\"").newLine(); + //.append(DottedChain.parseNoSuffix(variableName).toPrintableString(new LinkedHashSet<>(), getSwf(), false)).newLine(); } writer.append("]"); if (hasText) { @@ -1611,7 +1613,8 @@ public class DefineEditTextTag extends TextTag { public Map getNameProperties() { Map ret = super.getNameProperties(); if (variableName != null && !variableName.isEmpty()) { - ret.put("vn", DottedChain.parseNoSuffix(variableName).toPrintableString(new LinkedHashSet<>(), getSwf(), false)); + ret.put("vn", "\"" + Helper.escapePCodeString(variableName) + "\""); + //DottedChain.parseNoSuffix(variableName).toPrintableString(new LinkedHashSet<>(), getSwf(), false)); } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java index 3ba1fb5a8..a1ae0fac3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject2Tag.java @@ -36,6 +36,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import com.jpexs.decompiler.flash.types.filters.FILTER; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.ByteArrayRange; +import com.jpexs.helpers.Helper; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -459,7 +460,8 @@ public class PlaceObject2Tag extends PlaceObjectTypeTag implements ASMSourceCont public Map getNameProperties() { Map ret = super.getNameProperties(); if (placeFlagHasName) { - ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(new LinkedHashSet<>(), getSwf(), false)); + ret.put("nm", "\"" + Helper.escapePCodeString(name) + "\""); + //ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(new LinkedHashSet<>(), getSwf(), false)); } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java index 1b7b582cf..8abe38947 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject3Tag.java @@ -42,6 +42,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import com.jpexs.decompiler.flash.types.filters.FILTER; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.ByteArrayRange; +import com.jpexs.helpers.Helper; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -699,7 +700,8 @@ public class PlaceObject3Tag extends PlaceObjectTypeTag implements ASMSourceCont public Map getNameProperties() { Map ret = super.getNameProperties(); if (placeFlagHasName) { - ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(new LinkedHashSet<>(), getSwf(), false)); + ret.put("nm", "\"" + Helper.escapePCodeString(name) + "\""); + //ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(new LinkedHashSet<>(), getSwf(), false)); } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java index 6502ac2f3..975a406c2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java @@ -43,6 +43,7 @@ import com.jpexs.decompiler.flash.types.annotations.SWFVersion; import com.jpexs.decompiler.flash.types.filters.FILTER; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.ByteArrayRange; +import com.jpexs.helpers.Helper; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -712,7 +713,8 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont public Map getNameProperties() { Map ret = super.getNameProperties(); if (placeFlagHasName) { - ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(new LinkedHashSet<>(), getSwf(), false)); + ret.put("nm", "\"" + Helper.escapePCodeString(name) + "\""); + //ret.put("nm", DottedChain.parseNoSuffix(name).toPrintableString(new LinkedHashSet<>(), getSwf(), false)); } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/text/TextLexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/text/TextLexer.java index c8b617db0..3fa8024b4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/text/TextLexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/text/TextLexer.java @@ -73,14 +73,13 @@ public final class TextLexer { private static final String ZZ_ACTION_PACKED_0 = "\5\0\2\1\1\2\1\3\1\4\1\5\1\6\1\7"+ "\1\10\1\11\1\12\1\13\1\2\1\14\1\15\1\14"+ - "\1\16\1\2\1\17\1\20\1\21\1\22\1\23\1\24"+ - "\1\25\1\26\1\27\1\30\1\31\1\32\1\20\1\33"+ - "\1\34\1\35\1\36\1\37\1\40\1\41\3\20\1\42"+ - "\1\43\1\44\1\45\1\46\1\47\1\50\1\51\1\52"+ - "\2\42\6\0\1\53\1\54\2\0\1\55\1\0"; + "\1\2\1\16\1\17\1\20\1\21\1\22\1\23\1\24"+ + "\1\25\1\26\1\27\1\30\1\31\1\17\1\32\1\33"+ + "\1\34\1\35\1\36\1\37\1\40\3\17\1\41\1\42"+ + "\1\43\3\41\7\0\1\44\1\45\1\0\1\46"; private static int [] zzUnpackAction() { - int [] result = new int[69]; + int [] result = new int[62]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -107,16 +106,15 @@ public final class TextLexer { private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\32\0\64\0\116\0\150\0\202\0\234\0\202"+ "\0\202\0\266\0\202\0\320\0\352\0\u0104\0\202\0\202"+ - "\0\202\0\u011e\0\202\0\202\0\u0138\0\u0152\0\u016c\0\202"+ + "\0\202\0\u011e\0\202\0\202\0\u0138\0\u0152\0\202\0\202"+ "\0\202\0\202\0\202\0\202\0\202\0\202\0\202\0\202"+ - "\0\202\0\202\0\202\0\u0186\0\202\0\202\0\202\0\202"+ - "\0\202\0\202\0\202\0\u01a0\0\u01ba\0\u01d4\0\202\0\202"+ - "\0\202\0\202\0\202\0\202\0\202\0\202\0\202\0\u0186"+ - "\0\u01ee\0\u0208\0\u0222\0\u023c\0\u0256\0\u0270\0\u028a\0\202"+ - "\0\202\0\u01a0\0\u02a4\0\202\0\u0186"; + "\0\202\0\202\0\u016c\0\202\0\202\0\202\0\202\0\202"+ + "\0\202\0\202\0\u0186\0\u01a0\0\u01ba\0\202\0\202\0\202"+ + "\0\u0186\0\u01a0\0\u01d4\0\u01ee\0\u0208\0\u0222\0\u023c\0\u0256"+ + "\0\u0270\0\u028a\0\202\0\202\0\u0186\0\202"; private static int [] zzUnpackRowMap() { - int [] result = new int[69]; + int [] result = new int[62]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -146,36 +144,34 @@ public final class TextLexer { "\1\13\1\14\1\15\1\16\1\15\1\17\1\14\1\20"+ "\1\15\1\16\1\14\1\15\5\16\1\15\1\16\1\15"+ "\1\16\2\15\7\21\1\22\1\21\1\23\1\24\2\21"+ - "\1\25\14\21\7\26\1\27\1\30\1\10\3\26\1\10"+ - "\14\26\32\0\3\31\1\32\3\31\1\33\1\34\1\0"+ - "\3\31\1\0\1\35\1\36\1\37\1\40\1\41\1\42"+ - "\1\43\1\44\1\0\3\31\1\0\2\12\3\0\1\12"+ - "\4\0\2\12\2\0\5\12\1\0\1\12\1\0\1\12"+ - "\6\0\1\14\4\0\1\14\3\0\1\14\14\0\3\15"+ - "\2\0\3\15\3\0\2\15\1\0\15\15\2\16\2\0"+ - "\1\15\1\16\1\15\3\0\2\16\1\0\1\15\5\16"+ - "\1\15\1\16\1\15\1\16\2\15\7\31\1\45\1\31"+ - "\1\0\1\46\2\31\1\0\1\31\1\47\1\50\1\51"+ - "\1\52\1\53\1\31\1\54\1\0\1\55\1\56\1\31"+ - "\11\0\1\23\20\0\7\26\3\0\3\26\1\0\14\26"+ - "\7\57\1\60\1\61\1\0\3\57\1\0\1\57\1\62"+ - "\1\63\1\64\1\65\1\66\1\67\1\70\1\0\1\71"+ - "\2\57\2\0\1\72\2\0\2\72\4\0\1\72\3\0"+ - "\1\72\2\0\1\72\11\0\1\73\2\0\2\73\4\0"+ + "\1\25\23\21\1\26\1\27\1\10\3\21\1\10\14\21"+ + "\32\0\3\30\1\31\3\30\1\32\1\33\1\0\3\30"+ + "\1\0\1\34\1\35\1\36\1\37\1\40\1\41\1\42"+ + "\1\43\1\0\3\30\1\0\2\12\3\0\1\12\4\0"+ + "\2\12\2\0\5\12\1\0\1\12\1\0\1\12\6\0"+ + "\1\14\4\0\1\14\3\0\1\14\14\0\3\15\2\0"+ + "\3\15\3\0\2\15\1\0\15\15\2\16\2\0\1\15"+ + "\1\16\1\15\3\0\2\16\1\0\1\15\5\16\1\15"+ + "\1\16\1\15\1\16\2\15\7\30\1\44\1\30\1\0"+ + "\1\45\2\30\1\0\1\30\1\46\1\47\1\50\1\51"+ + "\1\52\1\30\1\53\1\0\1\54\1\55\1\30\11\0"+ + "\1\23\20\0\7\56\1\44\1\57\1\0\1\45\2\56"+ + "\1\0\1\56\1\46\1\47\1\50\1\51\1\52\1\60"+ + "\1\61\1\0\1\62\1\63\1\56\2\0\1\64\2\0"+ + "\2\64\4\0\1\64\3\0\1\64\2\0\1\64\11\0"+ + "\1\65\2\0\2\65\4\0\1\65\3\0\1\65\2\0"+ + "\1\65\11\0\1\66\2\0\2\66\4\0\1\66\3\0"+ + "\1\66\2\0\1\66\11\0\1\67\10\0\1\70\20\0"+ + "\1\71\10\0\1\72\20\0\1\73\2\0\2\73\4\0"+ "\1\73\3\0\1\73\2\0\1\73\11\0\1\74\2\0"+ "\2\74\4\0\1\74\3\0\1\74\2\0\1\74\11\0"+ - "\1\75\10\0\1\76\20\0\1\77\2\0\2\77\4\0"+ - "\1\77\3\0\1\77\2\0\1\77\11\0\1\100\2\0"+ - "\2\100\4\0\1\100\3\0\1\100\2\0\1\100\11\0"+ - "\1\101\2\0\2\101\4\0\1\101\3\0\1\101\2\0"+ - "\1\101\11\0\1\102\2\0\2\102\4\0\1\102\3\0"+ - "\1\102\2\0\1\102\11\0\1\75\10\0\1\75\1\103"+ - "\12\0\1\103\1\0\1\104\14\0\1\103\12\0\1\103"+ - "\1\0\1\104\2\0\1\105\2\0\2\105\4\0\1\105"+ - "\3\0\1\105\2\0\1\105\40\0\1\104"; + "\1\75\2\0\2\75\4\0\1\75\3\0\1\75\2\0"+ + "\1\75\11\0\1\67\10\0\1\67\1\72\12\0\1\72"+ + "\1\0\1\76\14\0\1\72\12\0\1\72\1\0\1\76"+ + "\2\0\1\71\10\0\1\71\15\0\1\76\31\0\1\76"; private static int [] zzUnpackTrans() { - int [] result = new int[702]; + int [] result = new int[676]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -214,11 +210,11 @@ public final class TextLexer { private static final String ZZ_ATTRIBUTE_PACKED_0 = "\5\0\1\11\1\1\2\11\1\1\1\11\3\1\3\11"+ - "\1\1\2\11\3\1\14\11\1\1\7\11\3\1\11\11"+ - "\2\1\6\0\2\11\2\0\1\11\1\0"; + "\1\1\2\11\2\1\14\11\1\1\7\11\3\1\3\11"+ + "\3\1\7\0\2\11\1\0\1\11"; private static int [] zzUnpackAttribute() { - int [] result = new int[69]; + int [] result = new int[62]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -301,7 +297,7 @@ public final class TextLexer { private StringBuilder string = null; private int repeatNum = 1; - + /** * Create an empty lexer, yyrset will be called later to reset and assign * the reader @@ -689,11 +685,11 @@ public final class TextLexer { case 1: { if (string == null) string = new StringBuilder(); string.append(yytext()); } - case 46: break; + case 39: break; case 2: { if (!parameter) { if (string == null) string = new StringBuilder(); string.append(yytext()); } } - case 47: break; + case 40: break; case 3: { parameter = true; yybegin(PARAMETER); @@ -703,47 +699,47 @@ public final class TextLexer { return new ParsedSymbol(SymbolType.TEXT, ret); } } - case 48: break; + case 41: break; case 4: { yybegin(VALUE); return new ParsedSymbol(SymbolType.PARAMETER_IDENTIFIER, yytext()); } - case 49: break; + case 42: break; case 5: { yybegin(YYINITIAL); parameter = false; } - case 50: break; + case 43: break; case 6: { } - case 51: break; + case 44: break; case 7: { return new ParsedSymbol(SymbolType.PARAMETER_VALUE, yytext()); } - case 52: break; + case 45: break; case 8: { return new ParsedSymbol(SymbolType.PARAMETER_IDENTIFIER, yytext()); } - case 53: break; + case 46: break; case 9: { string = new StringBuilder(); yybegin(STRING); } - case 54: break; + case 47: break; case 10: { string = new StringBuilder(); yybegin(OIDENTIFIER); } - case 55: break; + case 48: break; case 11: { for(int r=0;r { + \" { + yybegin(PARAMETER); + // length also includes the trailing quote + return token(TokenType.STRING, tokenStart, tokenLength + 1); } + + {StringCharacter}+ { tokenLength += yylength(); } + + \\[0-3]?{OctDigit}?{OctDigit} { tokenLength += yylength(); } + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(PARAMETER); } +} + + { + "\u00A7" { + yybegin(PARAMETER); + // length also includes the trailing quote + return token(TokenType.REGEX, tokenStart, tokenLength + 1); + } + + {OIdentifierCharacter}+ { tokenLength += yylength(); } + + + /* escape sequences */ + + \\. { tokenLength += 2; } + {LineTerminator} { yybegin(PARAMETER); } } /* error fallback */ diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 16708690a..87e26a75c 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -917,7 +917,8 @@ public class GenericTagTreePanel extends GenericTagPanel { if (di.exportName()) { valStr += " = " + escapeHtml(Helper.escapeExportname(swf, val.toString(), true)); } else { - valStr += " = " + escapeHtml(DottedChain.parseNoSuffix(val.toString()).toPrintableString(new LinkedHashSet<>(), swf, di.as3())); + valStr += " = " + escapeHtml("\"" + Helper.escapePCodeString(val.toString()) +"\""); + //escapeHtml(DottedChain.parseNoSuffix(val.toString()).toPrintableString(new LinkedHashSet<>(), swf, di.as3())); } } else if (val instanceof byte[]) { valStr += " = " + ((byte[]) val).length + " byte"; diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java index 58f481571..7f792755c 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java @@ -96,7 +96,8 @@ public class StringEditor extends JTextArea implements GenericTagEditor { if (di.exportName()) { newValue = Helper.escapeExportname(swf, newValue, false); } else { - newValue = DottedChain.parseNoSuffix(newValue).toPrintableString(new LinkedHashSet<>(), swf, di.as3()); + newValue = Helper.escapePCodeString(newValue); + //DottedChain.parseNoSuffix(newValue).toPrintableString(new LinkedHashSet<>(), swf, di.as3()); } } setText(newValue); @@ -115,7 +116,8 @@ public class StringEditor extends JTextArea implements GenericTagEditor { if (di.exportName()) { newValue = Helper.unescapeExportname(newValue); } else { - newValue = DottedChain.parsePrintable(newValue).toRawString(); + newValue = Helper.unescapePCodeString(newValue); + //DottedChain.parsePrintable(newValue).toRawString(); } }