--- old/src/jdk.xml.bind/share/classes/com/sun/xml/internal/dtdparser/InputEntity.java 2015-10-16 12:59:42.000000000 +0200 +++ new/src/jdk.xml.bind/share/classes/com/sun/xml/internal/dtdparser/InputEntity.java 2015-10-16 12:59:42.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,16 +36,17 @@ import java.io.Reader; import java.io.UnsupportedEncodingException; import java.net.URL; +import java.util.Arrays; import java.util.Locale; /** * This is how the parser talks to its input entities, of all kinds. * The entities are in a stack. - *

+ *

*

For internal entities, the character arrays are referenced here, * and read from as needed (they're read-only). External entities have * mutable buffers, that are read into as needed. - *

+ *

*

Note: This maps CRLF (and CR) to LF without regard for * whether it's in an external (parsed) entity or not. The XML 1.0 spec * is inconsistent in explaining EOL handling; this is the sensible way. @@ -148,11 +149,12 @@ InputStream bytes = in.getByteStream(); if (bytes == null) - reader = XmlReader.createReader(new URL(in.getSystemId()) - .openStream()); + if (Boolean.valueOf(System.getProperty("enableExternalEntityProcessing"))) + reader = XmlReader.createReader(new URL(in.getSystemId()).openStream()); + else + fatal("P-082", new Object[] {in.getSystemId()}); else if (in.getEncoding() != null) - reader = XmlReader.createReader(in.getByteStream(), - in.getEncoding()); + reader = XmlReader.createReader(in.getByteStream(), in.getEncoding()); else reader = XmlReader.createReader(in.getByteStream()); } @@ -169,7 +171,7 @@ throws SAXException { next = stack; - buf = b; + buf = Arrays.copyOf(b, b.length); finish = b.length; this.name = name; this.isPE = isPE; @@ -384,10 +386,10 @@ /** * normal content; whitespace in markup may be handled * specially if the parser uses the content model. - *

+ *

*

content terminates with markup delimiter characters, * namely ampersand (&) and left angle bracket (<). - *

+ *

*

the document handler's characters() method is called * on all the content found */ @@ -547,11 +549,11 @@ /** - * CDATA -- character data, terminated by "]]>" and optionally + * CDATA -- character data, terminated by {@code "]]>"} and optionally * including unescaped markup delimiters (ampersand and left angle * bracket). This should otherwise be exactly like character data, * modulo differences in error report details. - *

+ *

*

The document handler's characters() or ignorableWhitespace() * methods are invoked on all the character data found * @@ -620,7 +622,7 @@ continue; if (white) { - if (whitespaceInvalidMessage != null) + if (whitespaceInvalidMessage != null && errHandler != null) errHandler.error(new SAXParseException(DTDParser.messages.getMessage(locale, whitespaceInvalidMessage), null)); docHandler.ignorableWhitespace(buf, start, @@ -659,7 +661,7 @@ } } if (white) { - if (whitespaceInvalidMessage != null) + if (whitespaceInvalidMessage != null && errHandler != null) errHandler.error(new SAXParseException(DTDParser.messages.getMessage(locale, whitespaceInvalidMessage), null)); docHandler.ignorableWhitespace(buf, start, last - start); @@ -701,7 +703,7 @@ /** * whitespace in markup (flagged to app, discardable) - *

+ *

*

the document handler's ignorableWhitespace() method * is called on all the whitespace found */ @@ -759,7 +761,7 @@ /** * returns false iff 'next' string isn't as provided, * else skips that text and returns true. - *

+ *

*

NOTE: two alternative string representations are * both passed in, since one is faster. */ @@ -810,8 +812,9 @@ // to get rid of the symbol length constraint, since having // the wrong symbol is a fatal error anyway ... // - if (len > buf.length) - fatal("P-077", new Object[]{new Integer(buf.length)}); + if (len > buf.length) { + fatal("P-077", new Object[]{Integer.valueOf(buf.length)}); + } fillbuf(); return peek(next, chars); @@ -984,7 +987,9 @@ // not continuable ... e.g. WF errors close(); - errHandler.fatalError(x); + if (errHandler != null) { + errHandler.fatalError(x); + } throw x; } }