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

HttpBasicAuthenticator does not work if username or password contains certain special characters #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ousou
Copy link

@ousou ousou commented Nov 4, 2016

I noticed that the HttpBasicAuthenticator does not work if a username or password contains certain special characters, for instance Scandinavian letters (å, ä, ö). The login always fails in this case. The reason seems to be that the Base64-encoded string in the header is not correct, and the reason for this is that the conversion from String to Byte array in the method WebHelpers.Base64Encode does not handle special characters correctly.

For instance if the username is "testuser" and the password is "passwordä" then the correct Base64 encoded string is (this is given by for instance curl and base64 command line utilities):

dGVzdHVzZXI6cGFzc3dvcmTDpA==

but the Base64 encoded string given by the method WebHelpers.Base64Encode is

dGVzdHVzZXI6cGFzc3dvcmTk

I managed to fix this issue in a way that works for my use case by changing the String to Byte() conversion (see method StringConverter.Utf8BytesFromString). This code is taken from the page http://www.di-mgt.com.au/howto-convert-vba-unicode-to-utf8.html and modified to support 64bit Excel using the guide at http://stackoverflow.com/questions/21982682/code-does-not-work-on-64-bit-office. Unfortunately I didn't have the time to change the Base64Decode-method, so now if a string is first encoded and then decoded it might be changed. This pull request should thus not in any case be merged directly. I just made it to demonstrate how this issue can be fixed. Hopefully someone else can find a way to also fix the decoding method to work with special characters.

…trings (for instance Scandinavian letters). Fixes error where HTTP Basic Authentication fails when username or passwowrd contains special characters. Base64Decode is not changed in a corresponding way.
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.

1 participant