Closed Bug 1019169 Opened 7 years ago Closed 7 years ago

[NFC] Fix UTF <-> byte arrays conversions

Categories

(Firefox OS Graveyard :: NFC, defect)

x86
macOS
defect
Not set
normal

Tracking

(b2g-v2.0 fixed)

RESOLVED FIXED
2.0 S3 (6june)
Tracking Status
b2g-v2.0 --- fixed

People

(Reporter: kamituel, Assigned: kamituel)

References

Details

Attachments

(1 file, 1 obsolete file)

As was discovered in bug 1013845, we need to fix UTF <-> Uint8Array conversions in NFC. 

When we're handling user input, we get UCS-2 string, but fromUTF8()/toUTF8() in NfcUtils are assuming it's UTF-8. This causes them to return invalid values for some diacritic characters. 

Steps to reproduce:

> NfcUtils.toUTF8(NfcUtils.fromUTF8("łąka")) !== "łąka"  // true

Also, use of .chareCodeAt() is invalid, because it can return values > 255 and those get truncated in Uint8Array.
Blocks: 1013845
Attached file Pull request (obsolete) —
Fix for UTF8/16 <-> Uint8Array conversions, with test cases.
Attachment #8433547 - Flags: review?(alive)
Attachment #8433547 - Flags: review?(alive) → review?(gweng)
Comment on attachment 8433547 [details] [review]
Pull request

Since I'm not expert in text encoding, I can only read out that you removed the old manual encoding method with new Gecko APIs. If so, the patch looks good on me.
Attachment #8433547 - Flags: review?(gweng) → review+
Keywords: checkin-needed
Master: https://github.com/mozilla-b2g/gaia/commit/0f5dc07363da7a3f27e3ad5f1f7f957265e79bd8
Status: NEW → RESOLVED
Closed: 7 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 2.0 S3 (6june)
Reverted for frequent Gaia unit test failures.
Master: https://github.com/mozilla-b2g/gaia/commit/26978ca1619e7c2a50c6b1d9347dcaebe673f552

https://tbpl.mozilla.org/php/getParsedLog.php?id=41135842&tree=B2g-Inbound
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 2.0 S3 (6june) → ---
Sorry for this bug, I've got race condition where two patches landed in a short timeframe, that's why tests were passing on my machine and Travis.
Attachment #8433547 - Attachment is obsolete: true
Keywords: checkin-needed
Master: https://github.com/mozilla-b2g/gaia/commit/d367579e0891b61b3b2310746e72f9db926624f7
Status: REOPENED → RESOLVED
Closed: 7 years ago7 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 2.0 S3 (6june)
You need to log in before you can comment on or make changes to this bug.