Don't expand environment variables in wxFileName::MakeRelativeTo()
This could have been unexpected even if it worked as designed and, unlike with direct calls to Normalize(), there was no way to prevent this from happening. Worse, even when no expansion was done, the simple fact of calling wxExpandEnvVars() could result in replacing "dir\$file" with "dir$file" as the backslash is considered as an escape character by this function and hence break the file name structure. Closes #17977.
This commit is contained in:
@@ -1710,10 +1710,12 @@ bool wxFileName::MakeRelativeTo(const wxString& pathBase, wxPathFormat format)
|
||||
// get cwd only once - small time saving
|
||||
wxString cwd = wxGetCwd();
|
||||
|
||||
// Normalize the paths but avoid changing the case or turning a shortcut
|
||||
// into a file that it points to.
|
||||
const int normFlags = wxPATH_NORM_ALL &
|
||||
~(wxPATH_NORM_CASE | wxPATH_NORM_SHORTCUT);
|
||||
// Normalize both paths to be absolute but avoid expanding environment
|
||||
// variables in them, this could be unexpected.
|
||||
const int normFlags = wxPATH_NORM_DOTS |
|
||||
wxPATH_NORM_TILDE |
|
||||
wxPATH_NORM_ABSOLUTE |
|
||||
wxPATH_NORM_LONG;
|
||||
Normalize(normFlags, cwd, format);
|
||||
fnBase.Normalize(normFlags, cwd, format);
|
||||
|
||||
|
Reference in New Issue
Block a user