Skip to content
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

Should handle classloader URI as an absolute path when running on JRuby #3929

Closed
mojavelinux opened this issue Feb 1, 2021 · 6 comments
Closed
Assignees
Labels
bug v2.0.19 Issues resolved in the 2.0.19 release
Milestone

Comments

@mojavelinux
Copy link
Member

The virtual path represented by a classloader URI should be respected when running on JRuby. This means normalize_system_path should pass it through and is_uri? should return false.

@mojavelinux
Copy link
Member Author

ex. uri:classloader:/path/to/image

Note that ::File.absolute_path? (as well as Pathname#absolute?) recognizes this as an absolute path.

@mojavelinux mojavelinux added this to the v2.0.x milestone Feb 10, 2021
@mojavelinux mojavelinux changed the title normalize_system_path should respect classloader URI when running on JRuby Handle a classloader URI as an absolute path when running on JRuby Apr 14, 2021
@mojavelinux
Copy link
Member Author

There are several cases to consider here, not all of which go through normalize_system_path

  • read a stylesheet (to copy or embed)
  • read an image to embed
  • read an include file

@mojavelinux
Copy link
Member Author

read a stylesheet (to copy or embed)

This one is tougher. The reason is, the dest will end up being the src, and thus the stylesheet won't be copied. Dedicated logic will be required.

mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Apr 28, 2023
@mojavelinux mojavelinux modified the milestones: v2.x, v2.0.x Apr 29, 2023
@mojavelinux mojavelinux self-assigned this Apr 29, 2023
@mojavelinux mojavelinux changed the title Handle a classloader URI as an absolute path when running on JRuby Should handle classloader URI as an absolute path when running on JRuby Apr 29, 2023
@mojavelinux
Copy link
Member Author

mojavelinux commented Apr 29, 2023

This one is tougher. The reason is, the dest will end up being the src, and thus the stylesheet won't be copied. Dedicated logic will be required.

Actually, it's no problem after all. If stylesheet is a classloader URI, and linkcss is not set, it will be read and embedded. If linkcss and copycss are set, copycss must be the classloader URI and stylesheet must be the destination path. I'll make sure there are tests to cover these scenarios.

@mojavelinux
Copy link
Member Author

The one outstanding restriction is that if the safe mode is safe or greater, the resources will only be read if the base/jail is a parent classloader URI. We can revisit this restriction in a separate issue. The simplest workaround when mixing local paths and classloader URIs is to set the safe mode to unsafe.

mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Apr 29, 2023
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Apr 29, 2023
@mojavelinux
Copy link
Member Author

This fix will also prevent the following warning when including a file from the classloader:

cannot include contents of URI: uri:classloader:/path/to/include/file.adoc (allow-uri-read attribute not enabled)

mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Apr 30, 2023
mojavelinux added a commit to mojavelinux/asciidoctor that referenced this issue Apr 30, 2023
mojavelinux added a commit that referenced this issue May 1, 2023
@mojavelinux mojavelinux added the v2.0.19 Issues resolved in the 2.0.19 release label May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v2.0.19 Issues resolved in the 2.0.19 release
Projects
None yet
Development

No branches or pull requests

1 participant