-
Notifications
You must be signed in to change notification settings - Fork 791
GUACAMOLE-1972: Fix writing UTF-8 strings with surrogate pairs #999
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
base: staging/1.6.1
Are you sure you want to change the base?
Conversation
|
@scottp-dpaw Can you please re-base this against the |
cbe3525 to
2b9ec3c
Compare
|
Done, sorry about that! |
2b9ec3c to
b55b4c1
Compare
|
Fixed. I added a guard for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @scottp-dpaw, looks good to me.
@jmuehlner or @mike-jumper, any concerns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me - just a couple issues:
- Comparisons of integer values should definitely use
!==instead of!=. - There's a wonky null statement that crept in here - just accidentally double up on the semicolons.
| var codepoint = str.codePointAt ? str.codePointAt(i) : str.charCodeAt(i); | ||
|
|
||
| // For surrogate pairs, skip the second 16 bits. | ||
| if (str.charCodeAt(i) != codepoint) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comparison should use !== (same elsewhere).
| // Fill buffer with UTF-8 | ||
| for (var i=0; i<text.length; i++) { | ||
| var codepoint = text.charCodeAt(i); | ||
| var codepoint = text.codePointAt ? text.codePointAt(i) : text.charCodeAt(i);; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware you accidentally added an extra semicolon here (null statement).
No description provided.