IPP: don't replace unicode carriage return with character (EA-92213)

This commit is contained in:
Bas Leijdekkers
2016-11-23 11:31:37 +01:00
parent ad8c623aca
commit b837dc9d64
3 changed files with 5 additions and 1 deletions
@@ -110,7 +110,7 @@ public class UnicodeUnescapeIntention extends Intention {
/**
* see JLS 3.3. Unicode Escapes
*/
private static int indexOfUnicodeEscape(@NotNull String text, int offset) {
static int indexOfUnicodeEscape(@NotNull String text, int offset) {
final int length = text.length();
for (int i = 0; i < length; i++) {
final char c = text.charAt(i);
@@ -143,6 +143,8 @@ public class UnicodeUnescapeIntention extends Intention {
StringUtil.isHexDigit(text.charAt(nextChar + 3))) {
final int escapeEnd = nextChar + 4;
if (offset <= escapeEnd) {
final char d = (char)Integer.parseInt(text.substring(nextChar, nextChar + 4), 16);
if (d == '\r') return -1; // carriage return not allowed
return i;
}
}
@@ -0,0 +1 @@
// \u000D<caret>
@@ -29,6 +29,7 @@ public class UnicodeUnescapeIntentionTest extends IPPTestCase {
public void testSurrogatePairs2() { doTest(); }
public void testNoException() { assertIntentionNotAvailable(); }
public void testU() { assertIntentionNotAvailable(); }
public void testNoCarriageReturn() { assertIntentionNotAvailable(); }
@Override
protected String getRelativePath() {