8265106: IGV: Enforce en-US locale while parsing ideal graph

Co-authored-by: Roberto Castañeda Lozano <rcastanedalo@openjdk.org>
Reviewed-by: thartmann, chagedorn
This commit is contained in:
Yi Yang 2021-04-21 06:36:47 +00:00 committed by Tobias Hartmann
parent 3de0dcba78
commit b5c92ca34f
2 changed files with 9 additions and 0 deletions

View File

@ -34,6 +34,7 @@ import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.swing.SwingUtilities;
import javax.xml.parsers.ParserConfigurationException;
@ -529,6 +530,8 @@ public class Parser implements GraphParser {
}
try {
XMLReader reader = createReader();
// To enforce using English for non-English users, we must use Locale.ROOT rather than Locale.ENGLISH
reader.setProperty("http://apache.org/xml/properties/locale", Locale.ROOT);
reader.setContentHandler(new XMLParser(xmlDocument, monitor));
reader.parse(new InputSource(Channels.newInputStream(channel)));
} catch (SAXException ex) {

View File

@ -222,4 +222,10 @@ public class ParserTest {
testBoth(new GraphDocument(), "<graphDocument></graphDocument>");
}
@Test
public void testParseIncompleteXML() {
// Exception should be swallowed, see catch clause in GraphParser.parse.
testBoth(new GraphDocument(), "<graphDocument>");
}
}