fix escaping for chars in (127, 255]

This commit is contained in:
Dennis Ushakov
2015-08-11 14:52:50 +03:00
parent 8eea8eb13f
commit 695553d76d
2 changed files with 7 additions and 2 deletions
@@ -79,7 +79,7 @@ public class EscapeEntitiesAction extends SimpleCodeInsightAction {
char c = text.charAt(i);
final PsiElement element = file.findElementAt(start + i);
if (element != null && isCharacterElement(element)) {
if (c == '<' || c == '>' || c == '&' || c == '"' || c == '\'' || c > 0xff) {
if (c == '<' || c == '>' || c == '&' || c == '"' || c == '\'' || c > 0x7f) {
final String escape = ESCAPES.getValue(file).get(c);
if (escape != null) {
result.append("&").append(escape).append(";");
@@ -23,6 +23,7 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
*/
public class EscapeEntitiesActionTest extends LightCodeInsightFixtureTestCase {
private static final String NDASH = new String(new byte[]{-30, -128, -109}, CharsetToolkit.UTF8_CHARSET);
private static final String COPY = new String(new byte[]{-62, -82}, CharsetToolkit.UTF8_CHARSET);
public void testSimpleHtml() {
doTest("<<<", "html", "&lt;&lt;&lt;");
@@ -32,10 +33,14 @@ public class EscapeEntitiesActionTest extends LightCodeInsightFixtureTestCase {
doTest(">>>", "xml", "&gt;&gt;&gt;");
}
public void testWide() {
public void testVeryWide() {
doTest(NDASH, "html", "&ndash;");
}
public void testWide() {
doTest(COPY, "html", "&reg;");
}
public void testAttributeValue() {
doTest("<a alt='" + NDASH + "'></a>", "html", "<a alt='&ndash;'></a>");
}