Closed Ayowel closed 3 years ago
A quick fix, that works for me but is probably not desirable in the code base:
diff --git a/src/main/java/com/kodedu/controller/WebWorkerResource.java b/src/main/java/com/kodedu/controller/WebWorkerResource.java
index 1ed14be5..a3f9ccc4 100644
--- a/src/main/java/com/kodedu/controller/WebWorkerResource.java
+++ b/src/main/java/com/kodedu/controller/WebWorkerResource.java
@@ -99,6 +99,10 @@ public class WebWorkerResource {
}
if (optional.isPresent()) {
+ if(finalURI.startsWith("file:///")) {
+ finalURI = finalURI.replace("file:///", "");
+ }
+
Path found = directoryService.findPathInWorkdirOrLookup(IOHelper.getPath(finalURI));
if (Objects.nonNull(found)) {
What happens is that, for some reason, the front-end builds a path with file://
and send a request with it to the back-end when using an absolute path while it produces a 'native' absolute path when using relative paths in the include.
The code diff drops the file:///
prefix on the back-end but the actual fix should probably be implemented on the front-end, however I could not work out where the request was built
Hi,
Seems the change looks safe, but I'm not able to reproduce this issue on last release. What AsciidocFX version do you use ?
I'm using AsciidocFX 1.7.3 on windows 10. If i print {docdir}
it shows as C:\path\to\docdir
, if for some reason your docdir is a local path you probably won't have the issue
My worry is that the file://
issue might appear on linux too, in which case it probably works now but would be broken by this 'fix' as the linux equivalent would look like file:///path/to/docdir
and dropping file:///
would turn it into an invalid local path.
If you do not have control over the parsing/path generation, a fix that should be safer to integrate and is more explicit in what it checks for would be:
diff --git a/src/main/java/com/kodedu/controller/WebWorkerResource.java b/src/main/java/com/kodedu/controller/WebWorkerResource.java
index 1ed14be5..a3f9ccc4 100644
--- a/src/main/java/com/kodedu/controller/WebWorkerResource.java
+++ b/src/main/java/com/kodedu/controller/WebWorkerResource.java
@@ -99,6 +99,10 @@ public class WebWorkerResource {
}
if (optional.isPresent()) {
+ if(finalURI.matches("^file:///[A-Z]:[\\\\/].+$")) {
+ finalURI = finalURI.replace("file:///", "");
+ }
+
Path found = directoryService.findPathInWorkdirOrLookup(IOHelper.getPath(finalURI));
if (Objects.nonNull(found)) {
Fixed in ac80911
Hi,
As said in the title, it looks like absolute path includes do not work on windows for asciidoc files. They do seem to work for asciidoc files.
Example assuming a csv file
show.csv
in the same folder as the asciidoc file in workdir, usingdocdir
to get an absolute path to the workdir:show.csv
main.adoc
Error log: