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

Load libcurl-4.dll correctly even when there are umlauts in its absolute path #4575

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

dscho
Copy link
Member

@dscho dscho commented Aug 28, 2023

For historical reasons, the Win32 API provides *A() and *W() versions of many functions, e.g. LoadLibraryExA() and LoadLibraryExW(). The difference between these two function families is that the latter works on wide-character Unicode strings while the former accepts localized single- and multi-byte character sequences.

In Git for Windows's source code, we should not use the *A() family of functions at all because we use UTF-8 internally, which is not typically the current locale, and therefore the *A() functions will most often do unintended things. However, that's exactly what I did in #4410: using LoadLibraryExA() (I do not remember why, but can guess that I used it for testing and intended to replace it with the *W() invocation once everything works).

In this instance, the use of an *A() function prevents the libcurl-4.dll from being loaded correctly if its absolute path contains non-ASCII characters.

Let's fix this, and for good measure offer some sort of error message.

This fixes #4573.

If the `.dll` file could not be loaded, let's print an error message.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
NULL, err, LANG_NEUTRAL,
buf, sizeof(buf) - 1, NULL))
xsnprintf(buf, sizeof(buf), "last error: %ld", err);
error("LoadLibraryExA() failed with: %s", buf);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this error message mention LoadLibraryExW() instead as it's the function that is actually used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow `libcurl-4.dll` to be located in a path containing non-ASCII
characters.

This fixes git-for-windows#4573.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho force-pushed the lazyload-curl-with-umlauts-in-path branch from 55a4fd4 to 2f819d1 Compare August 28, 2023 12:23
@dscho
Copy link
Member Author

dscho commented Aug 30, 2023

/git-artifacts

The tag-git workflow run was started

@dscho
Copy link
Member Author

dscho commented Aug 30, 2023

/add release note bug As of Git for Windows v2.41.0, when installed into a location whose path contains non-ASCII characters, it was no longer possible to fetch from/push to remote repositories via https://, which has been fixed.

The workflow run was started

github-actions bot pushed a commit to git-for-windows/build-extra that referenced this pull request Aug 30, 2023
As of Git for Windows v2.41.0, when installed into a location whose path
contains non-ASCII characters, [it was no longer possible to fetch
from/push to remote repositories via
https://](git-for-windows/git#4573), which
[has been fixed](git-for-windows/git#4575).

Signed-off-by: gitforwindowshelper[bot] <gitforwindowshelper-bot@users.noreply.github.com>
@dscho
Copy link
Member Author

dscho commented Aug 30, 2023

/release

The release-git workflow run was started

@dscho dscho merged commit 2f819d1 into git-for-windows:main Aug 30, 2023
31 checks passed
@dscho dscho deleted the lazyload-curl-with-umlauts-in-path branch August 30, 2023 11:25
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

Successfully merging this pull request may close these issues.

"git ls-remote" fails with error about failing to load library libcurl-4.dll
2 participants