EA-92079 - NPE: XmlUtil.getCharFromEntityRef

reporting wrong entities
This commit is contained in:
Dmitry Avdeev
2018-10-10 19:08:58 +03:00
parent ec1985be8e
commit 08fb79d6be
2 changed files with 21 additions and 4 deletions
@@ -0,0 +1,18 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight;
import com.intellij.xml.util.XmlUtil;
import junit.framework.TestCase;
public class XmlUtilTest extends TestCase {
public void testDecodeEntityRef() {
assertEquals('&', XmlUtil.getCharFromEntityRef("&"));
try {
XmlUtil.getCharFromEntityRef("&unknown;");
fail("Exception should be thrown");
}
catch (AssertionError ignore) {
}
}
}
@@ -299,6 +299,9 @@ public class XmlUtil {
if (text.charAt(1) != '#') {
text = text.substring(1, text.length() - 1);
char c = XmlTagUtil.getCharacterByEntityName(text);
if (c == 0) {
LOG.error("Unknown entity: " + text);
}
return c == 0 ? ' ' : c;
}
text = text.substring(2, text.length() - 1);
@@ -320,10 +323,6 @@ public class XmlUtil {
catch (NumberFormatException e) {
return 0;
}
catch (NullPointerException e) {
LOG.error("Cannot parse ref: '" + text + "'", e);
return 0;
}
}
public static boolean attributeFromTemplateFramework(@NonNls final String name, final XmlTag tag) {