Merge origin/master

This commit is contained in:
Jindra Petřík
2016-03-05 07:57:10 +01:00
76 changed files with 530 additions and 152 deletions

View File

@@ -49,6 +49,7 @@ public class ActionNextFrame extends Action {
if (f < ((DisplayObject) lda.target).getTotalFrames()) {
((DisplayObject) lda.target).gotoFrame(f + 1);
}
return true;
}

View File

@@ -49,6 +49,7 @@ public class ActionPrevFrame extends Action {
if (f > 1) {
((DisplayObject) lda.target).gotoFrame(f - 1);
}
return true;
}

View File

@@ -53,6 +53,7 @@ public class ActionSetTarget extends Action {
lda.target = lda.stage;
return true;
}
lda.target = lda.stage.getMember(targetName);
return true;
}

View File

@@ -45,7 +45,7 @@ public class ActionAsciiToChar extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -50,6 +50,10 @@ public class ActionCall extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.isEmpty()) {
return false;
}
lda.stage.callFrame(EcmaScript.toInt32(lda.stack.pop()));
return true;
}

View File

@@ -45,7 +45,7 @@ public class ActionCharToAscii extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -50,6 +50,7 @@ public class ActionCloneSprite extends Action {
if (lda.stack.size() < 3) {
return false;
}
int depth = EcmaScript.toInt32(lda.stack.pop());
String source = EcmaScript.toString(lda.stack.pop());
String target = EcmaScript.toString(lda.stack.pop());

View File

@@ -48,6 +48,7 @@ public class ActionEndDrag extends Action {
if (lda.target instanceof DisplayObject) {
((DisplayObject) lda.target).stopDrag();
}
return true;
}

View File

@@ -52,6 +52,7 @@ public class ActionGetProperty extends Action {
if (lda.stack.size() < 2) {
return false;
}
int index = EcmaScript.toInt32(lda.stack.pop());
String target = EcmaScript.toString(lda.stack.pop());
Object movieClip = lda.stage.getMember(target);

View File

@@ -116,6 +116,7 @@ public class ActionGetURL2 extends Action {
if (lda.stack.size() < 2) {
return false;
}
String target = EcmaScript.toString(lda.stack.pop());
String urlString = EcmaScript.toString(lda.stack.pop());

View File

@@ -51,7 +51,7 @@ public class ActionGetVariable extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -109,9 +109,10 @@ public class ActionGotoFrame2 extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() < 1) {
if (lda.stack.isEmpty()) {
return false;
}
String frame = EcmaScript.toString(lda.stack.pop());
String target = "/";
if (frame.contains(":")) {

View File

@@ -110,7 +110,7 @@ public class ActionIf extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -45,7 +45,7 @@ public class ActionMBAsciiToChar extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -45,7 +45,7 @@ public class ActionMBCharToAscii extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -45,7 +45,7 @@ public class ActionMBStringLength extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -45,7 +45,7 @@ public class ActionNot extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -42,6 +42,7 @@ public class ActionPop extends Action {
if (lda.stack.isEmpty()) {
return false;
}
lda.stack.pop();
return true;
}

View File

@@ -45,9 +45,10 @@ public class ActionRandomNumber extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() < 1) {
if (lda.stack.isEmpty()) {
return false;
}
lda.stack.push(RandomNumberActionItem.getResult(lda.pop()));
return true;
}

View File

@@ -49,6 +49,7 @@ public class ActionRemoveSprite extends Action {
if (lda.stack.isEmpty()) {
return false;
}
String target = EcmaScript.toString(lda.stack.pop());
lda.stage.removeMember(target);
return true;

View File

@@ -59,6 +59,7 @@ public class ActionSetProperty extends Action {
if (lda.stack.size() < 3) {
return false;
}
Object value = lda.pop();
int index = (int) (double) lda.popAsNumber();
String target = lda.popAsString();

View File

@@ -48,6 +48,7 @@ public class ActionSetTarget2 extends Action {
if (lda.stack.isEmpty()) {
return false;
}
String target = lda.popAsString();
lda.target = lda.stage.getMember(target);
return true;

View File

@@ -50,6 +50,7 @@ public class ActionStartDrag extends Action {
if (lda.target instanceof DisplayObject) {
((DisplayObject) lda.target).startDrag();
}
return true;
}

View File

@@ -45,7 +45,7 @@ public class ActionStringLength extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -45,7 +45,7 @@ public class ActionToInteger extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -48,6 +48,7 @@ public class ActionTrace extends Action {
if (lda.stack.isEmpty()) {
return false;
}
lda.stage.trace(lda.pop());
return true;
}

View File

@@ -49,19 +49,20 @@ public class ActionCallFunction extends Action {
@Override
public boolean execute(LocalDataArea lda) {
String functionName = lda.popAsString();
int numArgs = (int) (double) lda.popAsNumber();
List<Object> args = new ArrayList<>();
for (int i = 0; i < numArgs; i++) {
args.add(lda.pop());
}
for (ActionScriptFunction f : lda.functions) {
if (functionName.equals(f.getFunctionName())) {
lda.stack.push(lda.stage.callFunction(f.getFunctionOffset(), f.getFunctionLength(), args, f.getFuncRegNames(), Undefined.INSTANCE /*?*/));
return true;
}
}
return true;
}

View File

@@ -51,12 +51,19 @@ public class ActionCallMethod extends Action {
if (lda.stack.size() < 3) {
return false;
}
String methodName = lda.popAsString();
ActionScriptObject obj = (ActionScriptObject) lda.pop();
Object obj0 = lda.pop();
if (!(obj0 instanceof ActionScriptObject)) {
return false;
}
ActionScriptObject obj = (ActionScriptObject) obj0;
int numArgs = (int) (double) lda.popAsNumber();
if (lda.stack.size() < numArgs) {
return false;
}
List<Object> args = new ArrayList<>();
for (int i = 0; i < numArgs; i++) {
args.add(lda.pop());

View File

@@ -45,7 +45,7 @@ public class ActionDecrement extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -47,11 +47,16 @@ public class ActionDelete2 extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.isEmpty()) {
return false;
}
String memberName = lda.popAsString();
Object o = lda.target; //should be current scope
if (o instanceof ActionScriptObject) {
((ActionScriptObject) o).setMember(memberName, Undefined.INSTANCE);
}
return true;
}

View File

@@ -50,6 +50,7 @@ public class ActionEnumerate extends Action {
if (lda.stack.isEmpty()) {
return false;
}
String objectName = lda.popAsString();
lda.stack.push(Null.INSTANCE);

View File

@@ -50,6 +50,7 @@ public class ActionGetMember extends Action {
if (lda.stack.size() < 2) {
return false;
}
String membername = lda.popAsString();
Object obj = lda.pop();
if (obj instanceof ActionScriptObject) {
@@ -57,6 +58,7 @@ public class ActionGetMember extends Action {
} else {
lda.stack.push(Undefined.INSTANCE);
}
return true;
}

View File

@@ -45,7 +45,7 @@ public class ActionIncrement extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -45,14 +45,17 @@ public class ActionInitArray extends Action {
if (lda.stack.isEmpty()) {
return false;
}
int num = (int) (double) lda.popAsNumber();
if (lda.stack.size() < num) {
return false;
}
ActionScriptArray arr = new ActionScriptArray();
for (int i = 0; i < num; i++) {
arr.setValueAtIndex(i, lda.stack.pop());
}
lda.stack.push(arr);
return true;
}

View File

@@ -50,16 +50,19 @@ public class ActionInitObject extends Action {
if (lda.stack.isEmpty()) {
return false;
}
int num = (int) (double) (Double) lda.popAsNumber();
if (lda.stack.size() < 2 * num) {
return false;
}
ActionScriptObject obj = new ActionScriptObject();
for (int i = 0; i < num; i++) {
Object val = lda.pop();
String name = lda.popAsString();
obj.setMember(name, val);
}
lda.stack.push(obj);
return true;
}

View File

@@ -51,16 +51,19 @@ public class ActionNewMethod extends Action {
if (lda.stack.size() < 3) {
return false;
}
String methodName = lda.popAsString();
ActionScriptObject obj = (ActionScriptObject) lda.pop();
int numArgs = (int) (double) lda.popAsNumber();
if (lda.stack.size() < numArgs) {
return false;
}
List<Object> args = new ArrayList<>();
for (int i = 0; i < numArgs; i++) {
args.add(lda.pop());
}
ActionScriptObject nobj = new ActionScriptObject();
ActionScriptFunction f = (ActionScriptFunction) obj.getMember(methodName);
lda.stage.callFunction(f.getFunctionOffset(), f.getFunctionLength(), args, f.getFuncRegNames(), nobj);

View File

@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.action.swf5;
import com.jpexs.decompiler.flash.BaseLocalData;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionScriptFunction;
import com.jpexs.decompiler.flash.action.ActionScriptObject;
import com.jpexs.decompiler.flash.action.LocalDataArea;
import com.jpexs.decompiler.flash.action.model.NewObjectActionItem;
@@ -51,19 +50,22 @@ public class ActionNewObject extends Action {
if (lda.stack.size() < 2) {
return false;
}
String objectName = lda.popAsString();
int numArgs = (int) (double) (Double) lda.popAsNumber();
if (lda.stack.size() < numArgs) {
return false;
}
List<Object> args = new ArrayList<>();
for (int i = 0; i < numArgs; i++) {
args.add(lda.stack.pop());
}
ActionScriptObject obj = new ActionScriptObject();
//TODO:check type
//TODO:check type
/*ActionScriptFunction constructor = (ActionScriptFunction) lda.stage.getMember(objectName);
lda.stage.callFunction(constructor.getFunctionOffset(), constructor.getFunctionLength(), args, constructor.getFuncRegNames(), obj);
lda.stage.callFunction(constructor.getFunctionOffset(), constructor.getFunctionLength(), args, constructor.getFuncRegNames(), obj);
*/
lda.stack.push(obj);
return true;

View File

@@ -46,7 +46,7 @@ public class ActionPushDuplicate extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -45,7 +45,7 @@ public class ActionReturn extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
//lda.returnValue = Undefined.INSTANCE;
return false;
} else {

View File

@@ -58,12 +58,14 @@ public class ActionSetMember extends Action {
if (lda.stack.size() < 3) {
return false;
}
Object value = lda.pop();
String memberName = lda.popAsString();
Object obj = lda.pop();
if (obj instanceof ActionScriptObject) {
((ActionScriptObject) obj).setMember(memberName, value);
}
return true;
}

View File

@@ -49,6 +49,7 @@ public class ActionTargetPath extends Action {
if (lda.stack.isEmpty()) {
return false;
}
Object obj = lda.pop();
String path = lda.stage.getMemberPath(obj);
@@ -57,6 +58,7 @@ public class ActionTargetPath extends Action {
} else {
lda.stack.push(path);
}
return true;
}

View File

@@ -45,7 +45,7 @@ public class ActionToNumber extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -45,7 +45,7 @@ public class ActionToString extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -45,7 +45,7 @@ public class ActionTypeOf extends Action {
@Override
public boolean execute(LocalDataArea lda) {
if (lda.stack.size() == 0) {
if (lda.stack.isEmpty()) {
return false;
}

View File

@@ -59,6 +59,7 @@ public class ActionWith extends Action implements GraphSourceItemContainer {
if (lda.stack.isEmpty()) {
return false;
}
ActionScriptObject obj = (ActionScriptObject) lda.pop();
ActionScriptWith w = new ActionScriptWith(obj, fileOffset, codeSize);
lda.withs.add(w);

View File

@@ -61,6 +61,7 @@ public class ActionEnumerate2 extends Action {
if (lda.stack.isEmpty()) {
return false;
}
Object o = lda.pop();
lda.stack.push(Null.INSTANCE);
@@ -70,6 +71,7 @@ public class ActionEnumerate2 extends Action {
lda.stack.push(m);
}
}
return true;
}
}

View File

@@ -72,6 +72,7 @@ public class ActionInstanceOf extends Action {
if (lda.stack.size() < 2) {
return false;
}
Object type = lda.stack.pop();
Object obj = lda.stack.pop();
if (getInstanceOfResult(obj, type)) {

View File

@@ -51,6 +51,7 @@ public class ActionCastOp extends Action {
if (lda.stack.size() < 2) {
return false;
}
ActionScriptObject obj = (ActionScriptObject) lda.pop();
ActionScriptObject constr = (ActionScriptObject) lda.pop();
if (ActionInstanceOf.getInstanceOfResult(obj, constr)) {
@@ -58,6 +59,7 @@ public class ActionCastOp extends Action {
} else {
lda.stack.push(Null.INSTANCE);
}
return true;
}

View File

@@ -49,6 +49,7 @@ public class ActionExtends extends Action {
if (lda.stack.size() < 2) {
return false;
}
//TODO: check if its really ActionScriptObject ?
ActionScriptObject superClass = (ActionScriptObject) lda.pop();
ActionScriptObject subClass = (ActionScriptObject) lda.pop();

View File

@@ -50,6 +50,7 @@ public class ActionImplementsOp extends Action {
if (lda.stack.size() < 2) {
return false;
}
//TODO: check if its really scriptobject?
ActionScriptObject obj = (ActionScriptObject) lda.pop();
int num = (int) (double) lda.popAsNumber();
@@ -57,9 +58,11 @@ public class ActionImplementsOp extends Action {
if (lda.stack.size() < num) {
return false;
}
for (int i = 0; i < num; i++) {
interfaces.add(lda.stack.pop());
}
obj.setImplementsObjs(interfaces);
return true;
}

View File

@@ -19,6 +19,8 @@ decompilationError.timeout.description = Non d\u00e9compil\u00e9 car le d\u00e9l
decompilationError.obfuscated = Le code est probablement obsfusqu\u00e9
decompilationError.errorType = Type d'erreur
decompilationError.error.description = Non d\u00e9compil\u00e9 car il y a des erreurs
decompilationError.actionCount = Nb d'actions :
decompilationError.instructionCount = Nb d'instructions :
decompilation.skipped = D\u00e9compilation abandonn\u00e9
decompilation.unsupported = Non support\u00e9 par le d\u00e9compileur

View File

@@ -12,7 +12,7 @@
* 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.xfl;
@@ -104,6 +104,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
import com.jpexs.decompiler.flash.types.sound.MP3FRAME;
import com.jpexs.decompiler.flash.types.sound.MP3SOUNDDATA;
import com.jpexs.decompiler.flash.types.sound.SoundFormat;
import com.jpexs.helpers.Helper;
import com.jpexs.helpers.Path;
import com.jpexs.helpers.SerializableImage;
import com.jpexs.helpers.utf8.Utf8Helper;
@@ -210,15 +211,32 @@ public class XFLConverter {
}
}
private static String getScaleMode(LINESTYLE lineStyle) {
if (lineStyle instanceof LINESTYLE2) {
LINESTYLE2 ls2 = (LINESTYLE2) lineStyle;
if (ls2.noHScaleFlag && ls2.noVScaleFlag) {
return "none";
} else if (ls2.noHScaleFlag) {
return "vertical";
} else if (ls2.noVScaleFlag) {
return "horizontal";
} else {
return "normal";
}
}
return "normal";
}
private static void convertLineStyle(LINESTYLE ls, int shapeNum, StringBuilder ret) {
ret.append("<SolidStroke weight=\"").append(((float) ls.width) / SWF.unitDivisor)
ret.append("<SolidStroke scaleMode=\"").append(getScaleMode(ls)).append("\" weight=\"").append(((float) ls.width) / SWF.unitDivisor)
.append("\">"
+ "<fill>"
+ "<SolidColor color=\"")
.append(ls.color.toHexRGB()).append("\"")
.append(shapeNum == 3 ? " alpha=\"" + ((RGBA) ls.color).getAlphaFloat() + "\"" : "").append(" />"
+ "</fill>"
+ "</SolidStroke>");
+ "</fill>"
+ "</SolidStroke>");
}
private static void convertLineStyle(HashMap<Integer, CharacterTag> characters, LINESTYLE2 ls, int shapeNum, StringBuilder ret) {
@@ -258,7 +276,7 @@ public class XFLConverter {
break;
}
ret.append("<SolidStroke weight=\"").append(((float) ls.width) / SWF.unitDivisor).append("\"");
ret.append("<SolidStroke scaleMode=\"").append(getScaleMode(ls)).append("\" weight=\"").append(((float) ls.width) / SWF.unitDivisor).append("\"");
ret.append(params);
ret.append(">");
ret.append("<fill>");
@@ -1051,7 +1069,7 @@ public class XFLConverter {
ret.append("<DOMSymbolInstance libraryItemName=\"" + "Symbol ").append(tag.getCharacterId()).append("\"");
if (name != null) {
ret.append(" name=\"").append(xmlString(name)).append("\"");
ret.append(" name=\"").append(Helper.escapeHTML(name)).append("\"");
}
String blendModeStr = null;
if (blendMode < BLENDMODES.length) {
@@ -1196,11 +1214,11 @@ public class XFLConverter {
boolean linkageExportForAS = false;
if (characterClasses.containsKey(symbol.getCharacterId())) {
linkageExportForAS = true;
symbolStr.append(" linkageClassName=\"").append(xmlString(characterClasses.get(symbol.getCharacterId()))).append("\"");
symbolStr.append(" linkageClassName=\"").append(Helper.escapeHTML(characterClasses.get(symbol.getCharacterId()))).append("\"");
}
if (characterVariables.containsKey(symbol.getCharacterId())) {
linkageExportForAS = true;
symbolStr.append(" linkageIdentifier=\"").append(xmlString(characterVariables.get(symbol.getCharacterId()))).append("\"");
symbolStr.append(" linkageIdentifier=\"").append(Helper.escapeHTML(characterVariables.get(symbol.getCharacterId()))).append("\"");
}
if (linkageExportForAS) {
symbolStr.append(" linkageExportForAS=\"true\"");
@@ -1517,7 +1535,7 @@ public class XFLConverter {
if (characterVariables.containsKey(symbol.getCharacterId())) {
linkageExportForAS = true;
mediaLinkStr += " linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
mediaLinkStr += " linkageIdentifier=\"" + Helper.escapeHTML(characterVariables.get(symbol.getCharacterId())) + "\"";
}
if (linkageExportForAS) {
mediaLinkStr += " linkageExportForAS=\"true\"";
@@ -1589,7 +1607,7 @@ public class XFLConverter {
}
if (characterVariables.containsKey(symbol.getCharacterId())) {
linkageExportForAS = true;
mediaLinkStr += " linkageIdentifier=\"" + xmlString(characterVariables.get(symbol.getCharacterId())) + "\"";
mediaLinkStr += " linkageIdentifier=\"" + Helper.escapeHTML(characterVariables.get(symbol.getCharacterId())) + "\"";
}
if (linkageExportForAS) {
mediaLinkStr += " linkageExportForAS=\"true\"";
@@ -1749,7 +1767,7 @@ public class XFLConverter {
StringBuilder ret = new StringBuilder();
ret.append("<DOMVideoInstance libraryItemName=\"movie").append(video.characterID).append(".flv\" frameRight=\"").append(20 * video.width).append("\" frameBottom=\"").append(20 * video.height).append("\"");
if (instanceName != null) {
ret.append(" name=\"").append(xmlString(instanceName)).append("\"");
ret.append(" name=\"").append(Helper.escapeHTML(instanceName)).append("\"");
}
ret.append(">");
ret.append("<matrix>");
@@ -2004,7 +2022,7 @@ public class XFLConverter {
if (hasAllRanges) {
embedRanges = "9999";
}
ret2.append("<DOMFontItem name=\"Font ").append(fontId).append("\" font=\"").append(xmlString(fontName)).append("\" size=\"0\" id=\"").append(fontId).append("\" embedRanges=\"").append(embedRanges).append("\"").append(!"".equals(embeddedCharacters) ? " embeddedCharacters=\"" + xmlString(embeddedCharacters) + "\"" : "").append(" />");
ret2.append("<DOMFontItem name=\"Font ").append(fontId).append("\" font=\"").append(Helper.escapeHTML(fontName)).append("\" size=\"0\" id=\"").append(fontId).append("\" embedRanges=\"").append(embedRanges).append("\"").append(!"".equals(embeddedCharacters) ? " embeddedCharacters=\"" + Helper.escapeHTML(embeddedCharacters) + "\"" : "").append(" />");
}
}
@@ -2190,7 +2208,7 @@ public class XFLConverter {
if (ret2.length() > 0) {
ret.append("<DOMLayer name=\"Layer ").append(layerIndex).append("\" color=\"").append(randomOutlineColor()).append("\">"
+ "<frames>").append(ret2).append("</frames>"
+ "</DOMLayer>");
+ "</DOMLayer>");
}
}
@@ -2402,7 +2420,7 @@ public class XFLConverter {
ret.append(" fontRenderingMode=\"").append(fontRenderingMode).append("\"");
}
if (instanceName != null) {
ret.append(" instanceName=\"").append(xmlString(instanceName)).append("\"");
ret.append(" instanceName=\"").append(Helper.escapeHTML(instanceName)).append("\"");
}
ret.append(antiAlias);
Map<String, Object> attrs = TextTag.getTextRecordsAttributes(textRecords, swf);
@@ -2469,7 +2487,7 @@ public class XFLConverter {
firstRun = false;
if (font != null) {
ret.append("<DOMTextRun>");
ret.append("<characters>").append(xmlString((newline ? "\r" : "") + rec.getText(font))).append("</characters>");
ret.append("<characters>").append(Helper.escapeHTML((newline ? "\r" : "") + rec.getText(font))).append("</characters>");
ret.append("<textAttrs>");
ret.append("<DOMTextAttrs aliasText=\"false\" rotation=\"true\" size=\"").append(twipToPixel(textHeight)).append("\" bitmapSize=\"").append(textHeight).append("\"");
@@ -2516,7 +2534,7 @@ public class XFLConverter {
ret.append(" fontRenderingMode=\"").append(fontRenderingMode).append("\"");
}
if (instanceName != null) {
ret.append(" name=\"").append(xmlString(instanceName)).append("\"");
ret.append(" name=\"").append(Helper.escapeHTML(instanceName)).append("\"");
}
ret.append(antiAlias);
double width = twipToPixel(bounds.getWidth());
@@ -2566,7 +2584,7 @@ public class XFLConverter {
ret.append(convertHTMLText(swf.getTags(), det, txt));
} else {
ret.append("<DOMTextRun>");
ret.append("<characters>").append(xmlString(txt)).append("</characters>");
ret.append("<characters>").append(Helper.escapeHTML(txt)).append("</characters>");
int leftMargin = -1;
int rightMargin = -1;
int indent = -1;
@@ -2844,7 +2862,7 @@ public class XFLConverter {
publishSettings.append(" <StreamUse8kSampleRate>0</StreamUse8kSampleRate>\n");
publishSettings.append(" <EventUse8kSampleRate>0</EventUse8kSampleRate>\n");
publishSettings.append(" <UseNetwork>").append(useNetwork ? 1 : 0).append("</UseNetwork>\n");
publishSettings.append(" <DocumentClass>").append(xmlString(characterClasses.containsKey(0) ? characterClasses.get(0) : "")).append("</DocumentClass>\n");
publishSettings.append(" <DocumentClass>").append(Helper.escapeHTML(characterClasses.containsKey(0) ? characterClasses.get(0) : "")).append("</DocumentClass>\n");
publishSettings.append(" <AS3Strict>2</AS3Strict>\n");
publishSettings.append(" <AS3Coach>4</AS3Coach>\n");
publishSettings.append(" <AS3AutoDeclare>4096</AS3AutoDeclare>\n");
@@ -3171,10 +3189,6 @@ public class XFLConverter {
return tparser.result;
}
private static String xmlString(String s) {
return s.replace("<", "&lt;").replace(">", "&gt;").replace("\"", "&quot;").replace("&", "&amp;").replace("\r\n", "&#xD;").replace("\r", "&#xD;").replace("\n", "&#xD;");
}
private static double twipToPixel(double tw) {
return tw / SWF.unitDivisor;
}
@@ -3383,7 +3397,7 @@ public class XFLConverter {
private void putText(String txt) {
result += "<DOMTextRun>";
result += "<characters>" + xmlString(txt) + "</characters>";
result += "<characters>" + Helper.escapeHTML(txt) + "</characters>";
result += "<textAttrs>";
result += "<DOMTextAttrs";
if (alignment != null) {

View File

@@ -1109,8 +1109,8 @@ public class Helper {
}
public static String escapeHTML(String text) {
String[] from = new String[]{"&", "<", ">", "\"", "'", "/"};
String[] to = new String[]{"&amp;", "&lt;", "&gt;", "&quot;", "&#x27;", "&#x2F;"};
String[] from = new String[]{"&", "<", ">", "\"", "'", "/", "\r\n", "\r", "\n"};
String[] to = new String[]{"&amp;", "&lt;", "&gt;", "&quot;", "&#x27;", "&#x2F;", "&#xD;", "&#xD;", "&#xD;"};
for (int i = 0; i < from.length; i++) {
text = text.replace(from[i], to[i]);
}