Repository: dita-ot/dita-ot
Issue: PDF2 build breakes due to an invalid xref's URI

Not sure if this is to be treated as a bug, an improvment or not at all, but in dita-3.3.3 one could generate a pdf2 document which contained an xref with an invalid URI, e.g.

`<xref format="pdf" href="file://ccm/temp/diff.pdf" scope="external">file</xref>`

The URI misses a 3 slash so that the authority component would be empty, instead it is //ccm/ which was not intended. It should have beed file:///ccm/temp/diff.pdf.

However, dita-3.6.1. aborts the build with an exception:
```
BUILD FAILED
C:\\bin\\dita-ot-3.6.1\\plugins\\org.dita.base\\build.xml:29: The following error occurred while executing this line:
C:\\bin\\dita-ot-3.6.1\\plugins\\org.dita.base\\build_preprocess2.xml:171: java.lang.IllegalArgumentException: URI has an authority component
	at java.io.File.<init>(File.java:423)
	at org.dita.dost.writer.ValidationFilter.validateReference(ValidationFilter.java:201)
	at org.dita.dost.writer.ValidationFilter.startElement(ValidationFilter.java:96)
	at org.dita.dost.writer.ProfilingFilter.startElement(ProfilingFilter.java:121)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)

```
## Expected Behavior
Depending on the processing-mode, e.g. lax, a PDF2 document is generated

## Actual Behavior
Build aborts with an exception

## Steps to Reproduce
Build the attached document

## Copy of the error message, log file or stack trace
```
BUILD FAILED
C:\\bin\\dita-ot-3.6.1\\plugins\\org.dita.base\\build.xml:29: The following error occurred while executing this line:
C:\\bin\\dita-ot-3.6.1\\plugins\\org.dita.base\\build_preprocess2.xml:171: java.lang.IllegalArgumentException: URI has an authority component
	at java.io.File.<init>(File.java:423)
	at org.dita.dost.writer.ValidationFilter.validateReference(ValidationFilter.java:201)
	at org.dita.dost.writer.ValidationFilter.startElement(ValidationFilter.java:96)
	at org.dita.dost.writer.ProfilingFilter.startElement(ProfilingFilter.java:121)
	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
```

## Environment
<!-- Include relevant details about the environment you experienced this in. -->

* DITA-OT version: 3.6.1
* Operating system and version: Windows
* How did you run DITA-OT? ant-launcher
* Transformation type: PDF
[authoring.zip](https://github.com/dita-ot/dita-ot/files/6181752/authoring.zip)


Changed files:
src/main/java/org/dita/dost/writer/ValidationFilter.java, src/test/java/org/dita/dost/writer/ValidationFilterTest.java

diff --git a/src/main/java/org/dita/dost/writer/ValidationFilter.java b/src/main/java/org/dita/dost/writer/ValidationFilter.java
index 371066c37..e887303e7 100644
--- a/src/main/java/org/dita/dost/writer/ValidationFilter.java
+++ b/src/main/java/org/dita/dost/writer/ValidationFilter.java
@@ -198,7 +198,7 @@ public final class ValidationFilter extends AbstractXMLFilter {
       try {
         final URI uri = new URI(href);
         final URI abs = currentFile.resolve(uri).normalize();
-        if (Objects.equals(abs.getScheme(), "file")) {
+        if (Objects.equals(abs.getScheme(), "file") && (abs.getAuthority() == null || abs.getAuthority().isEmpty())) {
           final File p = new File(URLUtils.setQuery(URLUtils.stripFragment(abs), null));
           try {
             final File canFile = p.getCanonicalFile();
diff --git a/src/test/java/org/dita/dost/writer/ValidationFilterTest.java b/src/test/java/org/dita/dost/writer/ValidationFilterTest.java
index c279e853a..c16837233 100644
--- a/src/test/java/org/dita/dost/writer/ValidationFilterTest.java
+++ b/src/test/java/org/dita/dost/writer/ValidationFilterTest.java
@@ -63,7 +63,7 @@ public class ValidationFilterTest {
   }
 
   @Test
-  public void testHref() throws SAXException, URISyntaxException {
+  public void testHref() throws SAXException {
     final List<String> res = new ArrayList<>();
     f.setContentHandler(
       new DefaultHandler() {
@@ -103,7 +103,35 @@ public class ValidationFilterTest {
   }
 
   @Test
-  public void testConref() throws SAXException, URISyntaxException {
+  public void testHref_networkFile() throws SAXException {
+    final List<String> res = new ArrayList<>();
+    f.setContentHandler(
+      new DefaultHandler() {
+        @Override
+        public void startElement(final String uri, final String localName, final String qName, final Attributes atts) {
+          res.add(atts.getValue(ATTRIBUTE_NAME_HREF));
+        }
+      }
+    );
+    final TestUtils.CachingLogger l = new TestUtils.CachingLogger();
+    f.setLogger(l);
+
+    f.startElement(
+      NULL_NS_URI,
+      TOPIC_XREF.localName,
+      TOPIC_XREF.localName,
+      new AttributesBuilder()
+        .add(ATTRIBUTE_NAME_HREF, "file://example.com/foo")
+        .add(ATTRIBUTE_NAME_SCOPE, ATTR_SCOPE_VALUE_EXTERNAL)
+        .build()
+    );
+
+    assertTrue(l.getMessages().isEmpty());
+    assertEquals("file://example.com/foo", res.get(0));
+  }
+
+  @Test
+  public void testConref() throws SAXException {
     final List<String> res = new ArrayList<>();
     f.setContentHandler(
       new DefaultHandler() {
@@ -137,7 +165,7 @@ public class ValidationFilterTest {
   }
 
   @Test
-  public void testScope() throws SAXException, URISyntaxException {
+  public void testScope() throws SAXException {
     final List<String> res = new ArrayList<>();
     f.setContentHandler(
       new DefaultHandler() {
@@ -173,7 +201,7 @@ public class ValidationFilterTest {
   }
 
   @Test
-  public void testId() throws SAXException, URISyntaxException {
+  public void testId() throws SAXException {
     f.setContentHandler(new DefaultHandler());
     final TestUtils.CachingLogger l = new TestUtils.CachingLogger();
     f.setLogger(l);
@@ -221,7 +249,7 @@ public class ValidationFilterTest {
   }
 
   @Test
-  public void testKeys() throws SAXException, URISyntaxException {
+  public void testKeys() throws SAXException {
     f.setContentHandler(new DefaultHandler());
     final TestUtils.CachingLogger l = new TestUtils.CachingLogger();
     f.setLogger(l);
@@ -268,7 +296,7 @@ public class ValidationFilterTest {
   }
 
   @Test
-  public void testKeyscope() throws SAXException, URISyntaxException {
+  public void testKeyscope() throws SAXException {
     f.setContentHandler(new DefaultHandler());
     final TestUtils.CachingLogger l = new TestUtils.CachingLogger();
     f.setLogger(l);