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

[FINE] API - use a utf-8 aware btoa implementation (base64encode) #3711

Merged
merged 1 commit into from
Apr 10, 2018
Merged

[FINE] API - use a utf-8 aware btoa implementation (base64encode) #3711

merged 1 commit into from
Apr 10, 2018

Conversation

himdel
Copy link
Contributor

@himdel himdel commented Apr 3, 2018

This is a fine version of:


window.btoa("sněhulák") fails on InvalidCharacterError: String contains an invalid character

because it only expects latin1 chars

We need to base64 encode the login:password pair even when the password uses non-latin1 chars :)

Implementation adapted from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_2_%E2%80%93_rewrite_the_DOMs_atob()_and_btoa()_using_JavaScript's_TypedArrays_and_UTF-8


Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1562798

`window.btoa("sněhulák")` fails on InvalidCharacterError: String contains an invalid character

because it only expects latin1 chars

We need to base64 encode the login:password pair even when the password uses non-latin1 chars :)

Implementation adapted from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_2_%E2%80%93_rewrite_the_DOMs_atob()_and_btoa()_using_JavaScript's_TypedArrays_and_UTF-8

(This corresponds to master PRs:
 * #3682 (updated to work in ES5, and dependencies via bower)
 * #3687 (not really needed because we're using the globals here)
 * #3709 (gaprindashvili fix removing a vendor mention, not really needed here)
)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1562798
@miq-bot
Copy link
Member

miq-bot commented Apr 3, 2018

Checked commit https://github.com/himdel/manageiq-ui-classic/commit/173cc7d63ba2fe70574631f34f24c11d9ae3b6e4 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
0 files checked, 0 offenses detected
Everything looks fine. ⭐

@simaishi simaishi merged commit 24c0741 into ManageIQ:fine Apr 10, 2018
@simaishi simaishi added this to the Sprint 83 Ending Apr 9, 2018 milestone Apr 10, 2018
@himdel himdel deleted the 58password-utf-bz1527316 branch April 10, 2018 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants