Skip to content

Commit

Permalink
#1732: systemId resolution regression introduced in 2.3.4+
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <[email protected]>
  • Loading branch information
lukasj committed Oct 12, 2023
1 parent 731a5f0 commit 20c8ed3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<listitem><para>
<link xlink:href="https://github.com/eclipse-ee4j/jaxb-ri/issues/1731">#1731</link>: Incompatibility with namespace when marshalling WebFault with FaultInfo on call of WebService
</para></listitem>
<listitem><para>
<link xlink:href="https://github.com/eclipse-ee4j/jaxb-ri/issues/1732">#1732</link>: systemId resolution regression introduced in 2.3.4+
</para></listitem>
<listitem><para>
<link xlink:href="https://github.com/eclipse-ee4j/jaxb-ri/issues/1736">#1736</link>: xjc: postProcessModel is not called for DTDs
</para></listitem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -40,8 +40,6 @@
import org.glassfish.jaxb.core.unmarshaller.DOMScanner;
import org.glassfish.jaxb.core.v2.util.XmlFactory;
import com.sun.xml.xsom.XSSchemaSet;
import java.nio.file.Files;
import java.nio.file.Paths;

import org.w3c.dom.Element;
import org.w3c.dom.ls.LSInput;
Expand Down Expand Up @@ -229,7 +227,8 @@ public LSInput resolveResource(String type, String namespaceURI, String publicId
// XSOM passes the namespace URI to the publicID parameter.
// we do the same here .
InputSource is = opts.entityResolver.resolveEntity(namespaceURI, systemId == null ? "" : systemId);
return isExists(is) ? new LSInputSAXWrapper(is) : null;
if (is == null) return null;
return new LSInputSAXWrapper(is);
} catch (SAXException | IOException e) {
// TODO: is this sufficient?
return null;
Expand Down Expand Up @@ -309,21 +308,6 @@ public void fatalError(SAXParseException exception) {
errorListener.fatalError(exception);
}

private static boolean isExists(InputSource is) {
if (is == null) {
return false;
}
try {
URI uri = new URI(is.getSystemId());
if ("file".equals(uri.getScheme())) {
return Files.exists(Paths.get(uri));
}
} catch (URISyntaxException ex) {
//ignore, let it be handled by parser as is
}
return true;
}

/**
* We use JAXP 1.3 to do a schema correctness check, but we know
* it doesn't always work. So in case some people hit the problem,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -43,10 +43,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;

import static org.glassfish.jaxb.core.v2.util.XmlFactory.allowExternalAccess;
Expand Down Expand Up @@ -267,26 +263,13 @@ public Document parse( String systemId, boolean root ) throws SAXException, IOEx
InputSource is=null;

// allow entity resolver to find the actual byte stream.
if( entityResolver!=null ) {
is = entityResolver.resolveEntity(null,systemId);
if (entityResolver != null) {
is = entityResolver.resolveEntity(null, systemId);
}
if (is == null) {
is = new InputSource(systemId);
} else {
try {
URI uri = new URI(is.getSystemId());
if ("file".equals(uri.getScheme())) {
if (!Files.exists(Paths.get(uri))) {
//resolved file does not exist, warn and let's continue with original systemId
errorReceiver.warning(null, Messages.format(
Messages.DOMFOREST_CATALOG_INVALID_ENTRY, is.getSystemId(), systemId));
is = new InputSource(systemId);
}
}
} catch (URISyntaxException ex) {
//ignore, let it be handled by parser as is
}
}

// but we still use the original system Id as the key.
return parse( systemId, is, root );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -70,7 +70,5 @@ static String format( String property, Object... args ) {
"ERR_GENERAL_SCHEMA_CORRECTNESS_ERROR";
static final String DOMFOREST_INPUTSOURCE_IOEXCEPTION = // arg:2
"DOMFOREST_INPUTSOURCE_IOEXCEPTION";
static final String DOMFOREST_CATALOG_INVALID_ENTRY = // arg:2
"DOMFOREST_CATALOG_INVALID_ENTRY";

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -95,6 +95,3 @@ ERR_FILENAME_IS_NOT_URI = \

DOMFOREST_INPUTSOURCE_IOEXCEPTION = \
IOException thrown when processing "{0}". Exception: {1}.

DOMFOREST_CATALOG_INVALID_ENTRY = \
Catalog points to non-existent resource: "{0}". Trying to reach "{1}" directly.

0 comments on commit 20c8ed3

Please sign in to comment.