diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 6f92d2f78..895ab324a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -914,7 +914,7 @@ public class AVM2Code implements Cloneable { if (info != null) { writer.appendNoHilight("method").newLine(); writer.appendNoHilight("name "); - writer.hilightSpecial(info.name_index == 0 ? "null" : "\"" + Helper.escapeString(info.getName(constants)) + "\"", HighlightSpecialType.METHOD_NAME); + writer.hilightSpecial(info.name_index == 0 ? "null" : "\"" + Helper.escapeActionScriptString(info.getName(constants)) + "\"", HighlightSpecialType.METHOD_NAME); writer.newLine(); if (info.flagExplicit()) { writer.appendNoHilight("flag "); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index c603bf140..1c9b8b53f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -211,7 +211,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { s.append(" null"); } else { s.append(" \""); - s.append(Helper.escapeString(constants.getString(operands[i]))); + s.append(Helper.escapeActionScriptString(constants.getString(operands[i]))); s.append("\""); } break; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java index aadab8442..c99741759 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 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.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -41,7 +42,7 @@ public class StringAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - return writer.append("\"" + Helper.escapeString(value) + "\""); + return writer.append("\"" + Helper.escapeActionScriptString(value) + "\""); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java index 643adb567..0da3a9766 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java @@ -191,7 +191,7 @@ public class Multiname { break; } } - return constants.getNamespace(index).getKindStr() + "(" + (name == null ? "null" : "\"" + Helper.escapeString(name) + "\"") + (sub > 0 ? ",\"" + sub + "\"" : "") + ")"; + return constants.getNamespace(index).getKindStr() + "(" + (name == null ? "null" : "\"" + Helper.escapeActionScriptString(name) + "\"") + (sub > 0 ? ",\"" + sub + "\"" : "") + ")"; } private static String namespaceSetToString(AVM2ConstantPool constants, int index) { @@ -222,16 +222,16 @@ public class Multiname { switch (kind) { case QNAME: case QNAMEA: - return getKindStr() + "(" + namespaceToString(constants, namespace_index) + "," + (name_index == 0 ? "null" : "\"" + Helper.escapeString(constants.getString(name_index)) + "\"") + ")"; + return getKindStr() + "(" + namespaceToString(constants, namespace_index) + "," + (name_index == 0 ? "null" : "\"" + Helper.escapeActionScriptString(constants.getString(name_index)) + "\"") + ")"; case RTQNAME: case RTQNAMEA: - return getKindStr() + "(" + (name_index == 0 ? "null" : "\"" + Helper.escapeString(constants.getString(name_index))) + "\"" + ")"; + return getKindStr() + "(" + (name_index == 0 ? "null" : "\"" + Helper.escapeActionScriptString(constants.getString(name_index))) + "\"" + ")"; case RTQNAMEL: case RTQNAMELA: return getKindStr() + "()"; case MULTINAME: case MULTINAMEA: - return getKindStr() + "(" + (name_index == 0 ? "null" : "\"" + Helper.escapeString(constants.getString(name_index)) + "\"") + "," + namespaceSetToString(constants, namespace_set_index) + ")"; + return getKindStr() + "(" + (name_index == 0 ? "null" : "\"" + Helper.escapeActionScriptString(constants.getString(name_index)) + "\"") + "," + namespaceSetToString(constants, namespace_set_index) + ")"; case MULTINAMEL: case MULTINAMELA: return getKindStr() + "(" + namespaceSetToString(constants, namespace_set_index) + ")"; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java index dd21cde9c..097adcda7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java @@ -137,7 +137,7 @@ public class ValueKind { ret = "" + constants.getDecimal(value_index); break; case CONSTANT_Utf8: - ret = "\"" + Helper.escapeString(constants.getString(value_index)) + "\""; + ret = "\"" + Helper.escapeActionScriptString(constants.getString(value_index)) + "\""; break; case CONSTANT_True: ret = "true"; @@ -179,7 +179,7 @@ public class ValueKind { ret = "Decimal(" + constants.getDecimal(value_index) + ")"; break; case CONSTANT_Utf8: - ret = "Utf8(\"" + Helper.escapeString(constants.getString(value_index)) + "\")"; + ret = "Utf8(\"" + Helper.escapeActionScriptString(constants.getString(value_index)) + "\")"; break; case CONSTANT_True: ret = "True"; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index 774f4d3de..3326e74d4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -603,7 +603,7 @@ public abstract class Action implements GraphSourceItem { for (String c : cPool.constantPool) { writer.appendNoHilight(constIdx); writer.appendNoHilight("|"); - writer.appendNoHilight(c); + writer.appendNoHilight(Helper.escapeString(c)); writer.newLine(); constIdx++; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index c568883a9..90db8cbd4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -166,10 +166,10 @@ public class DirectValueActionItem extends ActionItem { } } if (value instanceof String) { - return writer.append("\"" + Helper.escapeString((String) value) + "\""); + return writer.append("\"" + Helper.escapeActionScriptString((String) value) + "\""); } if (value instanceof ConstantIndex) { - return writer.append("\"" + Helper.escapeString(this.constants.get(((ConstantIndex) value).index)) + "\""); + return writer.append("\"" + Helper.escapeActionScriptString(this.constants.get(((ConstantIndex) value).index)) + "\""); } if (value instanceof RegisterNumber) { return writer.append(((RegisterNumber) value).translate()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java index 5615f3765..74c122f6b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java @@ -37,7 +37,7 @@ public class GetURLActionItem extends ActionItem { writer.append("getUrl"); writer.spaceBeforeCallParenthesies(2); writer.append("(\""); - writer.append(Helper.escapeString(urlString) + "\", \"" + Helper.escapeString(targetString)); + writer.append(Helper.escapeActionScriptString(urlString) + "\", \"" + Helper.escapeActionScriptString(targetString)); return writer.append("\")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java index 6aafb7abd..831384982 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 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.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -39,7 +40,7 @@ public class GotoLabelActionItem extends ActionItem { writer.append("gotoAndStop"); writer.spaceBeforeCallParenthesies(1); writer.append("(\""); - writer.append(Helper.escapeString(label)); + writer.append(Helper.escapeActionScriptString(label)); return writer.append("\")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java index 3eba4ce0a..dc2859480 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 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.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -36,7 +37,7 @@ public class SetTargetActionItem extends ActionItem { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("tellTarget(\""); - writer.append(Helper.escapeString(target)); + writer.append(Helper.escapeActionScriptString(target)); return writer.append("\")"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java index 319488487..4cfc966c0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java @@ -78,7 +78,7 @@ public class ActionGetURL extends Action { @Override public String toString() { - return "GetUrl \"" + Helper.escapeString(urlString) + "\" \"" + Helper.escapeString(targetString) + "\""; + return "GetUrl \"" + Helper.escapeActionScriptString(urlString) + "\" \"" + Helper.escapeActionScriptString(targetString) + "\""; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java index 887d1fa51..5a788489b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 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.swf3; import com.jpexs.decompiler.flash.SWFInputStream; @@ -47,7 +48,7 @@ public class ActionGoToLabel extends Action { @Override public String toString() { - return "GoToLabel \"" + Helper.escapeString(label) + "\""; + return "GoToLabel \"" + Helper.escapeActionScriptString(label) + "\""; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java index c6af7006c..eb3abbfde 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 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.swf3; import com.jpexs.decompiler.flash.SWFInputStream; @@ -47,7 +48,7 @@ public class ActionSetTarget extends Action { @Override public String toString() { - return "SetTarget \"" + Helper.escapeString(targetName) + "\""; + return "SetTarget \"" + Helper.escapeActionScriptString(targetName) + "\""; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 18d1c8e8d..ab88fd0e1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -279,7 +279,7 @@ public class ActionPush extends Action { ((ConstantIndex) values.get(i)).constantPool = constantPool; ret = ((ConstantIndex) values.get(i)).toString(); } else if (values.get(i) instanceof String) { - ret = "\"" + Helper.escapeString((String) values.get(i)) + "\""; + ret = "\"" + Helper.escapeActionScriptString((String) values.get(i)) + "\""; } else if (values.get(i) instanceof RegisterNumber) { ret = ((RegisterNumber) values.get(i)).toStringNoName(); } else { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java index 0eb1a4dc2..9a3de25dc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ConstantIndex.java @@ -55,7 +55,7 @@ public class ConstantIndex implements Serializable { if (Configuration.resolveConstants.get()) { if (constantPool != null) { if (index < constantPool.size()) { - return "\"" + Helper.escapeString(constantPool.get(index)) + "\""; + return "\"" + Helper.escapeActionScriptString(constantPool.get(index)) + "\""; } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java index 7adda9984..e3854d408 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 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.swf5; import com.jpexs.decompiler.flash.SWFInputStream; @@ -82,7 +83,7 @@ public class ActionConstantPool extends Action { StringBuilder ret = new StringBuilder(); ret.append("ConstantPool"); for (int i = 0; i < constantPool.size(); i++) { - ret.append(" \"").append(Helper.escapeString(constantPool.get(i))).append("\""); + ret.append(" \"").append(Helper.escapeActionScriptString(constantPool.get(i))).append("\""); } return ret.toString(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java index 0e30cd7ac..2163c730a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java @@ -113,10 +113,10 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { StringBuilder paramStr = new StringBuilder(); for (int i = 0; i < paramNames.size(); i++) { - paramStr.append("\"").append(Helper.escapeString(paramNames.get(i))).append("\" "); + paramStr.append("\"").append(Helper.escapeActionScriptString(paramNames.get(i))).append("\" "); } - return "DefineFunction \"" + Helper.escapeString(functionName) + "\" " + paramNames.size() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" +Action.actionsToString(getAddress() + getHeaderLength(),getItems(container) , knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}"; + return "DefineFunction \"" + Helper.escapeActionScriptString(functionName) + "\" " + paramNames.size() + " " + paramStr + " {" + (codeSize == 0 ? "\r\n}" : "");// + "\r\n" +Action.actionsToString(getAddress() + getHeaderLength(),getItems(container) , knownAddreses, constantPool, version, hex, getFileAddress() + hdrSize) + "}"; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java index d5695afd6..2677650ca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java @@ -202,10 +202,10 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont public String getASMSource(ActionList container, Set knownAddreses, ScriptExportMode exportMode) { StringBuilder paramStr = new StringBuilder(); for (int i = 0; i < paramNames.size(); i++) { - paramStr.append(paramRegisters.get(i)).append(" \"").append(Helper.escapeString(paramNames.get(i))).append("\" "); + paramStr.append(paramRegisters.get(i)).append(" \"").append(Helper.escapeActionScriptString(paramNames.get(i))).append("\" "); } - return ("DefineFunction2 \"" + Helper.escapeString(functionName) + "\" " + paramRegisters.size() + " " + registerCount + return ("DefineFunction2 \"" + Helper.escapeActionScriptString(functionName) + "\" " + paramRegisters.size() + " " + registerCount + " " + preloadParentFlag + " " + preloadRootFlag + " " + suppressSuperFlag diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java index dd60ac808..a75cf932b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionTry.java @@ -168,7 +168,7 @@ public class ActionTry extends Action implements GraphSourceItemContainer { if (catchInRegisterFlag) { ret.append("register").append(catchRegister); } else { - ret.append("\"").append(Helper.escapeString(catchName)).append("\""); + ret.append("\"").append(Helper.escapeActionScriptString(catchName)).append("\""); } ret.append(" "); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index b5cc1076c..021ce7565 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -189,7 +189,7 @@ public class DefineText2Tag extends TextTag { if (fnt == null) { writer.append(AppResources.translate("fontNotFound").replace("%fontId%", Integer.toString(rec.fontId))); } else { - writer.hilightSpecial(Helper.escapeString(rec.getText(fnt)).replace("[", "\\[").replace("]", "\\]"), HighlightSpecialType.TEXT); + writer.hilightSpecial(Helper.escapeActionScriptString(rec.getText(fnt)).replace("[", "\\[").replace("]", "\\]"), HighlightSpecialType.TEXT); } } return new HighlightedText(writer); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index b3579f9c4..a077b7afb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -189,7 +189,7 @@ public class DefineTextTag extends TextTag { if (fnt == null) { writer.append(AppResources.translate("fontNotFound").replace("%fontId%", Integer.toString(rec.fontId))); } else { - writer.hilightSpecial(Helper.escapeString(rec.getText(fnt)).replace("[", "\\[").replace("]", "\\]"), HighlightSpecialType.TEXT); + writer.hilightSpecial(Helper.escapeActionScriptString(rec.getText(fnt)).replace("[", "\\[").replace("]", "\\]"), HighlightSpecialType.TEXT); } } return new HighlightedText(writer); diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index 7a0295f82..b9900862a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -181,8 +181,38 @@ public class Helper { ret.append("\\t"); } else if (c == '\b') { ret.append("\\b"); + } else if (c == '\f') { + ret.append("\\f"); + } else if (c == '\\') { + ret.append("\\\\"); + } else if (c < 32) { + ret.append("\\x").append(padZeros(Integer.toHexString((int) c), 2)); + } else { + ret.append(c); + } + } + + return ret.toString(); + } + + /** + * Escapes string by adding backslashes + * + * @param s String to escape + * @return Escaped string + */ + public static String escapeActionScriptString(String s) { + StringBuilder ret = new StringBuilder(s.length()); + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + if (c == '\n') { + ret.append("\\n"); + } else if (c == '\r') { + ret.append("\\r"); } else if (c == '\t') { ret.append("\\t"); + } else if (c == '\b') { + ret.append("\\b"); } else if (c == '\f') { ret.append("\\f"); } else if (c == '\\') { @@ -219,8 +249,6 @@ public class Helper { ret.append("\\t"); } else if (c == '\b') { ret.append("\\b"); - } else if (c == '\t') { - ret.append("\\t"); } else if (c == '\f') { ret.append("\\f"); } else if (c == '\\') { @@ -237,6 +265,96 @@ public class Helper { return ret.toString(); } + /** + * Unescapes a string that contains standard Java escape sequences. + * + * + * @param st + * A string optionally containing standard java escape sequences. + * @return The translated string. + */ + public static String unescapeJavaString(String st) { + + StringBuilder sb = new StringBuilder(st.length()); + + for (int i = 0; i < st.length(); i++) { + char ch = st.charAt(i); + if (ch == '\\') { + char nextChar = (i == st.length() - 1) ? '\\' : st + .charAt(i + 1); + // Octal escape? + if (nextChar >= '0' && nextChar <= '7') { + String code = "" + nextChar; + i++; + if ((i < st.length() - 1) && st.charAt(i + 1) >= '0' + && st.charAt(i + 1) <= '7') { + code += st.charAt(i + 1); + i++; + if ((i < st.length() - 1) && st.charAt(i + 1) >= '0' + && st.charAt(i + 1) <= '7') { + code += st.charAt(i + 1); + i++; + } + } + sb.append((char) Integer.parseInt(code, 8)); + continue; + } + + switch (nextChar) { + case '\\': + ch = '\\'; + break; + case 'b': + ch = '\b'; + break; + case 'f': + ch = '\f'; + break; + case 'n': + ch = '\n'; + break; + case 'r': + ch = '\r'; + break; + case 't': + ch = '\t'; + break; + case '\"': + ch = '\"'; + break; + case '\'': + ch = '\''; + break; + // Hex Unicode: u???? + case 'u': + if (i >= st.length() - 5) { + ch = 'u'; + break; + } + int code = Integer.parseInt( + "" + st.charAt(i + 2) + st.charAt(i + 3) + + st.charAt(i + 4) + st.charAt(i + 5), 16); + sb.append(Character.toChars(code)); + i += 5; + continue; + } + + i++; + } + + sb.append(ch); + } + + return sb.toString(); + } + public static String getValidHtmlId(String text) { // ID and NAME tokens must begin with a letter ([A-Za-z]) and // may be followed by any number of letters, digits ([0-9]), @@ -863,7 +981,7 @@ public class Helper { String[] parts = line.split("\\|", 2); if (parts.length >= 2) { - cPool.add(parts[1]); + cPool.add(unescapeJavaString(parts[1])); } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java b/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java index 17c8b0146..54f3504cd 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ConstantsListModel.java @@ -91,7 +91,7 @@ public class ConstantsListModel implements ListModel { case TYPE_DECIMAL: return (index + 1) + ":" + constants.getDecimal(index + 1); case TYPE_STRING: - return (index + 1) + ":" + Helper.escapeString(constants.getString(index + 1)); + return (index + 1) + ":" + Helper.escapeActionScriptString(constants.getString(index + 1)); case TYPE_NAMESPACE: return (index + 1) + ":" + constants.getNamespace(index + 1).getNameWithKind(constants); case TYPE_NAMESPACESET: diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 0852bcd76..5ae3abf54 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -796,7 +796,6 @@ public class ActionPanel extends JPanel implements SearchListener