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

bug: export::path:absolute function fails when TS_RS_EXPORT_DIR is set to an absolute path and the path_bug test is executed #322

Closed
escritorio-gustavo opened this issue May 23, 2024 · 0 comments · Fixed by #323
Labels
bug Something isn't working

Comments

@escritorio-gustavo
Copy link
Contributor

escritorio-gustavo commented May 23, 2024

Describe the bug
Certain combinations of absolute paths and ../. path components can trick the aboslute function into doing nothing

To Reproduce

  1. Create a file in this repo at .cargo/config.toml with the following content:
[env]
TS_RS_EXPORT_DIR = { value = "./whatever", relative = true }
  1. Run cargo test

Why is this happening?
The path ./whatever is automatically transformed into an absolute path by cargo due to the relative flag.
The path_bug test checks if exporting to ../somewhere/ works.
The paths are combined into something like /usr/me/../somewhere and passed into the absolute function.
The absolute function, seeing the path starts at the root directory / assumes this is already an absolute path and does nothing
The diff_paths function, not expecting the absolute function to return a path containing . or .., panics

Version
8.1.0

@escritorio-gustavo escritorio-gustavo added the bug Something isn't working label May 23, 2024
@escritorio-gustavo escritorio-gustavo changed the title bug: export::path:absolute bug: export::path:absolute function fails when TS_RS_EXPORT_DIR is set to an absolute path and the path_bug test is executed May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant