--- old/jaxws/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/NGCCRuntimeEx.java 2017-02-14 14:26:17.148431228 +0300 +++ new/jaxws/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/NGCCRuntimeEx.java 2017-02-14 14:26:17.048430588 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -34,7 +34,6 @@ import com.sun.xml.internal.xsom.impl.Const; import com.sun.xml.internal.xsom.impl.parser.state.NGCCRuntime; import com.sun.xml.internal.xsom.impl.parser.state.Schema; -import com.sun.xml.internal.xsom.impl.util.Uri; import com.sun.xml.internal.xsom.parser.AnnotationParser; import com.sun.xml.internal.org.relaxng.datatype.ValidationContext; import org.xml.sax.Attributes; @@ -48,8 +47,10 @@ import java.io.IOException; import java.net.URI; +import java.net.URL; import java.text.MessageFormat; import java.util.Stack; +import java.util.regex.Pattern; /** * NGCCRuntime extended with various utility methods for @@ -150,12 +151,15 @@ /* registers a patcher that will run after all the parsing has finished. */ + @Override public void addPatcher( Patch patcher ) { parser.patcherManager.addPatcher(patcher); } + @Override public void addErrorChecker( Patch patcher ) { parser.patcherManager.addErrorChecker(patcher); } + @Override public void reportError( String msg, Locator loc ) throws SAXException { parser.patcherManager.reportError(msg,loc); } @@ -188,8 +192,15 @@ EntityResolver er = parser.getEntityResolver(); String systemId = null; - if (relativeUri!=null) - systemId = Uri.resolve(baseUri,relativeUri); + if (relativeUri!=null) { + if (isAbsolute(relativeUri)) { + systemId = relativeUri; + } + if (baseUri == null || !isAbsolute(baseUri)) { + throw new IOException("Unable to resolve relative URI " + relativeUri + " because base URI is not absolute: " + baseUri); + } + systemId = new URL(new URL(baseUri), relativeUri).toString(); + } if (er!=null) { InputSource is = er.resolveEntity(namespaceURI,systemId); @@ -217,7 +228,20 @@ } } - /** Includes the specified schema. */ + private static final Pattern P = Pattern.compile(".*[/#?].*"); + + private static boolean isAbsolute(String uri) { + int i = uri.indexOf(':'); + if (i < 0) { + return false; + } + return !P.matcher(uri.substring(0, i)).matches(); + } + + /** + * Includes the specified schema. + * @param schemaLocation + * @throws org.xml.sax.SAXException */ public void includeSchema( String schemaLocation ) throws SAXException { NGCCRuntimeEx runtime = new NGCCRuntimeEx(parser,chameleonMode,this); runtime.currentSchema = this.currentSchema; @@ -235,7 +259,11 @@ true, currentSchema.getTargetNamespace(), getLocator() ); } - /** Imports the specified schema. */ + /** + * Imports the specified schema. + * @param ns + * @param schemaLocation + * @throws org.xml.sax.SAXException */ public void importSchema( String ns, String schemaLocation ) throws SAXException { NGCCRuntimeEx newRuntime = new NGCCRuntimeEx(parser,false,this); InputSource source = resolveRelativeURL(ns,schemaLocation); @@ -317,9 +345,13 @@ /** * Parses the specified entity. * + * @param source * @param importLocation * The source location of the import/include statement. * Used for reporting errors. + * @param includeMode + * @param expectedNamespace + * @throws org.xml.sax.SAXException */ public void parseEntity( InputSource source, boolean includeMode, String expectedNamespace, Locator importLocation ) throws SAXException { @@ -342,6 +374,7 @@ /** * Creates a new instance of annotation parser. + * @return */ public AnnotationParser createAnnotationParser() { if(parser.getAnnotationParserFactory()==null) @@ -351,14 +384,15 @@ } /** - * Gets the element name that contains the annotation element. - * This method works correctly only when called by the annotation handler. + * Gets the element name that contains the annotation element.This method works correctly only when called by the annotation handler. + * @return */ public String getAnnotationContextElementName() { return elementNames.get( elementNames.size()-2 ); } - /** Creates a copy of the current locator object. */ + /** Creates a copy of the current locator object. + * @return */ public Locator copyLocator() { return new LocatorImpl(getLocator()); } @@ -397,6 +431,7 @@ this.uri = _uri; } + @Override public String resolveNamespacePrefix(String p) { if(p.equals(prefix)) return uri; if(previous==null) return null; @@ -408,14 +443,18 @@ private final Context previous; // XSDLib don't use those methods, so we cut a corner here. + @Override public String getBaseUri() { return null; } + @Override public boolean isNotation(String arg0) { return false; } + @Override public boolean isUnparsedEntity(String arg0) { return false; } } private Context currentContext=null; - /** Returns an immutable snapshot of the current context. */ + /** Returns an immutable snapshot of the current context. + * @return */ public ValidationContext createValidationContext() { return currentContext; } @@ -446,6 +485,7 @@ * Parses UName under the given context. * @param qname Attribute name. * @return New {@link UName} instance based on attribute name. + * @throws org.xml.sax.SAXException */ public UName parseUName(final String qname ) throws SAXException { int idx = qname.indexOf(':');