mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed Convert triple-quoted string: loses data in case of double quote inside the string and leads to syntax error
This commit is contained in:
+1
-9
@@ -95,16 +95,8 @@ public class PyConvertTripleQuotedStringIntention extends BaseIntentionAction {
|
||||
subString = convertToValidSubString(trimmed.substring(0, trimmed.length() - 3), firstQuote);
|
||||
}
|
||||
else {
|
||||
s = StringUtil.escapeStringCharacters(s);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (Character ch : s.toCharArray()) {
|
||||
if (ch == firstQuote) {
|
||||
stringBuilder.append("\\").append(firstQuote);
|
||||
}
|
||||
else {
|
||||
stringBuilder.append(ch);
|
||||
}
|
||||
}
|
||||
stringBuilder = StringUtil.escapeStringCharacters(s.length(), s, String.valueOf(firstQuote), true, stringBuilder);
|
||||
subString = stringBuilder.toString();
|
||||
}
|
||||
return subString;
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
s = ("\n"
|
||||
"my quote\" some text after it\n"
|
||||
)
|
||||
@@ -0,0 +1,3 @@
|
||||
s = """
|
||||
my q<caret>uote" some text after it
|
||||
"""
|
||||
@@ -237,10 +237,15 @@ public class PyIntentionTest extends PyTestCase {
|
||||
public void testConvertVariadicParam() { //PY-2264
|
||||
doTest(PyBundle.message("INTN.convert.variadic.param"));
|
||||
}
|
||||
|
||||
public void testConvertTripleQuotedString() { //PY-2697
|
||||
doTest(PyBundle.message("INTN.triple.quoted.string"));
|
||||
}
|
||||
|
||||
public void testConvertTripleQuotedString1() { //PY-7774
|
||||
doTest(PyBundle.message("INTN.triple.quoted.string"));
|
||||
}
|
||||
|
||||
public void testTransformConditionalExpression() { //PY-3094
|
||||
doTest(PyBundle.message("INTN.transform.into.if.else.statement"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user