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

Windows-style pathnames cause problems in IOUtils.resolveFileOrResource() #1768

Open
mstubenschrott opened this issue Nov 26, 2021 · 0 comments

Comments

@mstubenschrott
Copy link

For some unimportant reason, we have sometimes windows style path names with backslashes in our config files when we do development on Windows. In our test cases, we load the config.xml from a Java resource. However, IOUtils.resolveFileOrResource() does not treat the backslashes correctly.

The resulting URL:

INFO o.m.c.u.i.IOUtils:205 Resolved scenarios\config.xml to file:/C:/.../target/classes/scenarios%5ccconfig.xml

has the backslashes converted to %5c. It can indeed be read, so that's not the immediate problem, but that path also ends up in Config.setContext() and later in IOUtils.extendUrl(). The extendUrl() however does not work correctly and puts relative paths now relative to file:/C:/.../target/classes/ instead of file:/C:/.../target/classes/scenarios

A simple fix would be to just replace all backslashes with forward slashes in IOUtils.resolveFileOrResource(). If you want Linux users to be able to use \ as a valid filename character, that replacing may only happen in the windows world (although I would never advise somebody to use \ inside a filename anyway :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant