-
Notifications
You must be signed in to change notification settings - Fork 42
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
Fix pathconv issues related to relative paths in path lists #213
Fix pathconv issues related to relative paths in path lists #213
Conversation
winsup/cygwin/msys2_path_conv.cc
Outdated
/* | ||
* Discern between Git's `<rev>:<path>`, SCP's `<host>:<path>` pattern | ||
* (which is not a path list but may naïvely look like one) on the one | ||
* hand, and path lists starting with `/<path>`, `./<path>` or `../<path>` | ||
* on the other hand. | ||
*/ | ||
bool potential_path_list = *it == '/' || | ||
(*it == '.' && | ||
(it[1] == ':' || it[1] == '/' || | ||
(it[1] == '.' && | ||
(it[2] == ':' || it[2] == '/')))); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | |
* Discern between Git's `<rev>:<path>`, SCP's `<host>:<path>` pattern | |
* (which is not a path list but may naïvely look like one) on the one | |
* hand, and path lists starting with `/<path>`, `./<path>` or `../<path>` | |
* on the other hand. | |
*/ | |
bool potential_path_list = *it == '/' || | |
(*it == '.' && | |
(it[1] == ':' || it[1] == '/' || | |
(it[1] == '.' && | |
(it[2] == ':' || it[2] == '/')))); | |
/* | |
* Discern between Git's `<rev>:<path>`, SCP's `<host>:<path>` pattern | |
* (which is not a path list but may naively look like one) on the one | |
* hand, and path lists starting with `/<path>`, `./<path>` or `../<path>` | |
* on the other hand. | |
*/ | |
bool potential_path_list = *it == '/' || | |
(*it == '.' && | |
(it + 1 == end || it[1] == '\0' || it[1] == ':' || it[1] == '/' || | |
(it[1] == '.' && | |
(it + 2 == end || it[2] == '\0' || it[2] == ':' || it[2] == '/')))); | |
- Watch for end-of-string / end of input.
- This file mostly doesn't use tabs.
- Let's not introduce a character
ï
that isn't encoded the same in iso-latin1 and utf-8 (there are no others in this file yet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ReinhardBiegelIntech, what do you think?
(This replaces a deleted comment which tagged @ reneparis. Apologies, René.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked your code and agree on your suggestions - so let's wait for reinhard (currently on vacation) to implement it as soon as he's back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback, @bustercopley. Suggestions look good to me, so I updated the PR accordingly. Also committed to test suite.
As the changes affect code originally written bei @dscho, I'd also like to get his feedback here.
…nvironment variables to Windows form for native Win32 applications. When we fixed MSYS2's automatic Unix <-> Windows path conversion to identify and skip Git-style `<rev>:<path>` arguments (and incidentally also scp-style `<host>:<path>` ones), we assumed that path lists containing relative paths would be a rare scenario. My, was this assumption wrong! Let's add another heuristic that detects absolute paths at the beginning of path lists, and relative ones starting with either `./` or `../`, neither of which match those Git-style nor scp-style arguments, and then prevent the detection of the latter style from kicking in. This addresses msys2#208 Signed-off-by: Johannes Schindelin <[email protected]>
…ables assigned on command line This restores parts of the previous behavior of path_conv, fixing an issue where the paths of the path list in `VARIABLE=.:../foo/bar ./my-script.sh` weren't convertet to windows paths. The path conversion was skipped due to interpretation as a Git style reference. The Git detection is now excluded for this kind of variable assignments.
Suggested-by: Richard Copley <[email protected]>
7b2484f
to
a907109
Compare
Seems like this doesn't match any maintainer's idea of how to address #208, so im closing here. |
Implementation associated with testsuite changes here: msys2/msys2-tests#67
Only tested in testsuite yet.
@dscho