diff --git a/src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/ByteCodeParser.java b/src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/ByteCodeParser.java index 0809e83b..541164e2 100644 --- a/src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/ByteCodeParser.java +++ b/src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/ByteCodeParser.java @@ -1043,7 +1043,7 @@ private void parseLDC(DefaultStack stack, ConstantPool constants, in break; case Constant.CONSTANT_String: int stringIndex = ((ConstantString)constant).getStringIndex(); - stack.push(new StringConstantExpression(lineNumber, StringUtil.escapeString(constants.getConstantString(stringIndex)))); + stack.push(new StringConstantExpression(lineNumber, constants.getConstantString(stringIndex))); break; } } diff --git a/src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/StringUtil.java b/src/main/java/org/jd/core/v1/service/fragmenter/javasyntaxtojavafragment/util/StringUtil.java similarity index 88% rename from src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/StringUtil.java rename to src/main/java/org/jd/core/v1/service/fragmenter/javasyntaxtojavafragment/util/StringUtil.java index c2191f3d..4d7fbda0 100644 --- a/src/main/java/org/jd/core/v1/service/converter/classfiletojavasyntax/util/StringUtil.java +++ b/src/main/java/org/jd/core/v1/service/fragmenter/javasyntaxtojavafragment/util/StringUtil.java @@ -5,20 +5,19 @@ * copy and modify the code freely for non-commercial purposes. */ -package org.jd.core.v1.service.converter.classfiletojavasyntax.util; +package org.jd.core.v1.service.fragmenter.javasyntaxtojavafragment.util; public class StringUtil { public static String escapeString(String s) { int length = s.length(); - int i = 0; - for (; i < length; i++) { + for (int i = 0; i < length; i++) { char c = s.charAt(i); - if ((c == '\\') || (c < ' ')) { - StringBuilder sb = new StringBuilder(length * 2 + 2); + if ((c == '\\') || (c == '"') || (c < ' ')) { + StringBuilder sb = new StringBuilder(length * 2); sb.append(s.substring(0, i)); diff --git a/src/main/java/org/jd/core/v1/service/fragmenter/javasyntaxtojavafragment/visitor/ExpressionVisitor.java b/src/main/java/org/jd/core/v1/service/fragmenter/javasyntaxtojavafragment/visitor/ExpressionVisitor.java index de3ccba4..a935ff6a 100644 --- a/src/main/java/org/jd/core/v1/service/fragmenter/javasyntaxtojavafragment/visitor/ExpressionVisitor.java +++ b/src/main/java/org/jd/core/v1/service/fragmenter/javasyntaxtojavafragment/visitor/ExpressionVisitor.java @@ -24,6 +24,7 @@ import org.jd.core.v1.service.converter.classfiletojavasyntax.util.PrimitiveTypeUtil; import org.jd.core.v1.service.fragmenter.javasyntaxtojavafragment.util.CharacterUtil; import org.jd.core.v1.service.fragmenter.javasyntaxtojavafragment.util.JavaFragmentFactory; +import org.jd.core.v1.service.fragmenter.javasyntaxtojavafragment.util.StringUtil; import org.jd.core.v1.util.DefaultList; import java.util.HashSet; @@ -529,7 +530,7 @@ public void visit(PreOperatorExpression expression) { @Override public void visit(StringConstantExpression expression) { tokens.addLineNumberToken(expression); - tokens.add(new StringConstantToken(expression.getString(), currentInternalTypeName)); + tokens.add(new StringConstantToken(StringUtil.escapeString(expression.getString()), currentInternalTypeName)); } @Override