-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retract version 2.0.3 #7
Comments
asciidoctorj-diagram hasn't been released yet, therefore IntelliJ hasn't upgraded yet. No harm done! As you pulled release 2.0.3, the master of asciidoctorj-diagram will probably fail to build. Depending on when you plan to publish a new 2.0.4 version it is up to @robertpanzer to decide if he wants to wait, or to roll back the master to 2.0.2. |
ASAP. I've already reproduced the issue and know how to fix it; but the day job takes precedence. |
@pepijnve I am just experimenting with 2.0.4 and I am not sure if there is a new issue. File inputFile = new File("build/resources/test/sample.adoc");
File outputFile1 = new File(inputFile.getParentFile(), "asciidoctor-diagram-process.png");
File outputFile2 = new File(inputFile.getParentFile(), ".asciidoctor/diagram/asciidoctor-diagram-process.png.cache");
asciidoctor.requireLibrary("asciidoctor-diagram");
asciidoctor.convertFile(inputFile,
options()
.backend("html5")
.toDir(new File("build"))
.get());
assertThat(outputFile1.exists(), is(true)); // fails here
assertThat(outputFile2.exists(), is(true)); using this document: = Document Title
[ditaa,asciidoctor-diagram-process]
....
+-------------+
| Asciidoctor |-------+
| diagram | |
+-------------+ | PNG out
^ |
| ditaa in |
| v
+--------+ +--------+----+ /---------------\
| |---+ Asciidoctor +--->| |
| Text | +-------------+ | Beautiful |
|Document| | !magic! | | Output |
| {d}| | | | |
+---+----+ +-------------+ \---------------/
: ^
| Lots of work |
+-----------------------------------+
....
This test fails in the check if outputFile1 exists. Instead of |
Argh, can't seem to get this release right... I'll check in a minute. |
Looking at this on a bigger screen, it does look like the expected behaviour. asciidoctor-diagram writes to (in this order, first defined value)
since you're specifying Are you seeing different behaviour wrt 2.0.2 or earlier? |
The same test worked with 2.0.2 with the same version of AsciidoctorJ (and hence Asciidoctor), so something seems to have changed since then. |
Ok, that's what I suspected. In 2.0.2 the logic to pick the output dir was
the 2.0.4 version is
should do the same thing I would think, so I don't really understand where the difference is coming from. |
I'll debug tomorrow, maybe I can find a difference. |
Debugging through Now
In Unsafe mode it works as expected and I see that my test is plain wrong, instead of assuming the resulting image in the documents source directory it should of course be in the :to_dir. However in safe mode, 2.0.2 produces the file in the documents source directory Am I missing sth about safe mode? That said, I'll happily update the test to use unsafe mode, fix the test accordingly and release asciidoctorj-diagram 2.0.4. |
Oh wow, I didn't expect that at all. Why is |
@robertpanzer I'm not seeing the same behaviour locally. Entering That gets passed on to Finally the path resolution logic resolves the path, everything checks out and I get the correct absolute path back. No double concatenated absolute paths in sight. |
As you have observed, normalize_system_path knows how to deal with an absolute path. However, if it determines that the absolute path is outside of the jail, then it will modify it because it is trying to prevent access a forbid location. So the real question is, why does it think the path is outside the jail? Keep in mind that safe mode will enforce the jail whereas unsafe mode will not. |
@mojavelinux thanks for the pointer. So this is expected behaviour. Looks like a test setup issue then where safe mode is being used with an incorrect jail. |
All I am setting is the :out_dir option. |
@robertpanzer in safe mode the jail directory is
and
The jail will be Even if I fix this, with the test setup above diagram is still going to want to try to write to |
@robertpanzer asciidoctor/asciidoctor-diagram@669fa3c is an attempt to make things more predictable. I've split the path handling logic into two parts: resolving relative paths to absolute ones and normalising paths which enforces the safe mode jail. This should avoid the premature jailing of paths which can lead to unexpected results. Do you have a way of testing a git version of the gem or should I make a prerelease build for testing? |
@pepijnve Awesome, thank you! |
Ok, well that's progress already. I must have missed something with the cache then. Let me double check. |
It was another double normalisation that I missed. @robertpanzer could you give asciidoctor/asciidoctor-diagram@ae697ff a try? |
@robertpanzer I've been able to reproduce the issue in a test case myself. It boils down to the way safe mode works when the output directory is not equal to or a child of the parent directory of the source file. The diagram extension is deriving the paths you expect internally, but safe mode normalisation kicks in and changes them. This is the path getting normalised. In the end because There's a simple fix for this problem: don't test this kind of setup 😄 What's a bit surprising though is that the backend does manage to write outside the jail (at least that's what it looks like since @mojavelinux afaict from the source code this is by design. Could you confirm that this is the case? |
@robertpanzer I wasn't sure which variant we want. If I pass an absolute path to normalize_system_path with no start value you get the double absolute path. If I pass a file name and the absolute path of the desired directory you get the behaviour your currently seeing. Neither is really what you would want or expect. If you want to specify a cache directory explicitly, you can do that since 2.0.3 using the |
@robertpanzer I was going through the diagram issue list and bumped into asciidoctor/asciidoctor-diagram#262 Exact same problem as what you're describing. As @mojavelinux stated there, this is kind of a core issue related to how safe mode works. My intuitive expectation would be that the safe mode jail consists of two distinct roots: one for input and one for output. You can only read from the source documents parent directory and only write to the destination directory. Changing that is out of scope for this issue of course. I think with the last set of fixes I did we're in a good enough state. I'm going to close this issue for the time being. |
Sorry for responding late, I am drowning a bit in work and other personal issues right now. But thank you for digging out this issue. Under that condition I guess it is fine as it is, and the personal recommendation probably has to be to never use it :D |
No worries Robert, I know the feeling. My available time to work on open source stuff ebs and flows as my day job and personal life get busier and calmer as well. |
asciidoctor/asciidoctor-diagram#292 pointed to a rather bad regression in 2.0.3 when rerendering diagrams. I've pulled 2.0.3 from rubygems.org already. I think we should do the same for the java version.
@ahus1 not sure if this affects the IntelliJ plugin already, but don't upgrade to 2.0.3 just yet.
The text was updated successfully, but these errors were encountered: