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

Add extension support for non-english names #1619

Merged
merged 4 commits into from
Oct 30, 2022

Conversation

damianhxy
Copy link
Member

Description

Replace use of btoa with custom base 64 encoder obtained from MDN.

(Note that it uses the deprecated substr method, I've replaced it with substring which is equivalent since we start from index 0).

Motivation and Context

Currently, it is generally not possible to create an extension for students with non-english names.

For reasons (see #931), we are base64 encoding student names and looking them up in a dictionary. However, btoa "expects to be passed binary data, and will throw an exception if the given string contains any characters whose UTF-16 representation occupies more than one byte."

On the other hand, Ruby's Base64.strict_encode64 handles it just fine. Hence this PR replaces the base64 encoding algorithm on the frontend.

Closes #1466

How Has This Been Tested?

  • Create a student with a chinese name (e.g. 小明)
  • Give student an extension successfully
  • Also test that we can still give extensions to students with english names

Screen Shot 2022-10-03 at 22 41 49

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have run rubocop for style check. If you haven't, run overcommit --install && overcommit --sign to use pre-commit hook for linting

Copy link
Contributor

@victorhuangwq victorhuangwq left a comment

Choose a reason for hiding this comment

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

Works as expected.
LGTM

@victorhuangwq
Copy link
Contributor

victorhuangwq commented Oct 30, 2022

works with 😀 now as well

@damianhxy damianhxy merged commit 375e630 into master Oct 30, 2022
@damianhxy damianhxy deleted the extensions-support-chinese branch October 30, 2022 01:16
damianhxy added a commit that referenced this pull request Nov 6, 2022
- file was removed in #1619
- file was commented out in #1016
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.

Unable to create an extension
2 participants