mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-92079 - NPE: XmlUtil.getCharFromEntityRef
reporting wrong entities
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user