Skip to content

Add extension support for non-english names#1619

Merged
damianhxy merged 4 commits into
masterfrom
extensions-support-chinese
Oct 30, 2022
Merged

Add extension support for non-english names#1619
damianhxy merged 4 commits into
masterfrom
extensions-support-chinese

Conversation

@damianhxy

Copy link
Copy Markdown
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

@victorhuangwq victorhuangwq left a comment

Copy link
Copy Markdown
Contributor

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

victorhuangwq commented Oct 30, 2022

Copy link
Copy Markdown
Contributor

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