[jaxb~v2:556cde30] Fix 14348987 - invalid absolute URL

  • From: snajper@...
  • To: commits@...
  • Subject: [jaxb~v2:556cde30] Fix 14348987 - invalid absolute URL
  • Date: Tue, 6 Aug 2013 11:03:22 +0000

Project:    jaxb
Repository: v2
Revision:   556cde308377908affe257785a1fd7e4e85a2a4b
Author:     snajper
Date:       2013-08-06 10:54:19 UTC
Link:       

Log Message:
------------
Fix 14348987 - invalid absolute URL



Revisions:
----------
556cde308377908affe257785a1fd7e4e85a2a4b


Modified Paths:
---------------
jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/internalizer/AbstractReferenceFinderImpl.java


Diffs:
------
--- 
a/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/internalizer/AbstractReferenceFinderImpl.java
+++ 
b/jaxb-ri/xjc/src/main/java/com/sun/tools/xjc/reader/internalizer/AbstractReferenceFinderImpl.java
@@ -40,29 +40,27 @@
 
 package com.sun.tools.xjc.reader.internalizer;
 
-import java.io.IOException;
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-
 import com.sun.istack.SAXParseException2;
-
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.XMLFilterImpl;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
 /**
  * XMLFilter that finds references to other schema files from
  * SAX events.
- *
+ * <p/>
  * This implementation is a base implementation for typical case
  * where we just need to look for a particular attribute which
  * contains an URL to another schema file.
  *
- * @author
- *  Kohsuke Kawaguchi (kohsuke.kawaguchi@...)
+ * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@...)
  */
 public abstract class AbstractReferenceFinderImpl extends XMLFilterImpl {
 
@@ -76,12 +74,9 @@ public abstract class AbstractReferenceFinderImpl extends 
XMLFilterImpl {
      * IF the given element contains a reference to an external resource,
      * return its URL.
      *
-     * @param nsURI
-     *      Namespace URI of the current element
-     * @param localName
-     *      Local name of the current element
-     * @return
-     *      It's OK to return a relative URL.
+     * @param nsURI     Namespace URI of the current element
+     * @param localName Local name of the current element
+     * @return It's OK to return a relative URL.
      */
     protected abstract String findExternalResource(String nsURI, String 
localName, Attributes atts);
 
@@ -98,16 +93,21 @@ public abstract class AbstractReferenceFinderImpl extends 
XMLFilterImpl {
             // absolutize URL.
             String lsi = locator.getSystemId();
             String ref;
-            if (lsi.startsWith("jar:")) {
-                int bangIdx = lsi.indexOf('!');
-                if (bangIdx > 0) {
-                    ref = lsi.substring(0, bangIdx + 1)
-                            + new URI(lsi.substring(bangIdx + 
1)).resolve(new URI(relativeRef)).toString();
+            URI relRefURI = new URI(relativeRef);
+            if (relRefURI.isAbsolute())
+                ref = relativeRef;
+            else {
+                if (lsi.startsWith("jar:")) {
+                    int bangIdx = lsi.indexOf('!');
+                    if (bangIdx > 0) {
+                        ref = lsi.substring(0, bangIdx + 1)
+                                + new URI(lsi.substring(bangIdx + 
1)).resolve(new URI(relativeRef)).toString();
+                    } else {
+                        ref = relativeRef;
+                    }
                 } else {
-                    ref = relativeRef;
+                    ref = new URI(lsi).resolve(new 
URI(relativeRef)).toString();
                 }
-            } else {
-                ref = new URI(lsi).resolve(new URI(relativeRef)).toString();
             }
 
             // then parse this schema as well,
@@ -136,6 +136,7 @@ public abstract class AbstractReferenceFinderImpl extends 
XMLFilterImpl {
             throw spe;
         }
     }
+
     private Locator locator;
 
     @Override
@@ -143,4 +144,4 @@ public abstract class AbstractReferenceFinderImpl extends 
XMLFilterImpl {
         super.setDocumentLocator(locator);
         this.locator = locator;
     }
-};
+}





[jaxb~v2:556cde30] Fix 14348987 - invalid absolute URL

snajper 08/06/2013
Terms of Use; Privacy Policy; Copyright ©2013-2015 (revision 20150226.965aeb8)
 
 
Close
loading
Please Confirm
Close