IIUC, the reason that LocalStroage behaves incorrectly for the cases in comment 6 is that LocalStorage relies on tranforming `nsString` between `nsCString`. The browser test in comment 13 is used to make it easier to constently reproduce the issue. I wrote a gtest in comment 14 to prove if we convert `u"\udfff"` from a UTF16 string to a UTF8 string and then converting it back to the UTF16 string. The contents of the UTF16 strings are different. That means we probaby need to consider changing the code in [1, 2]. [1] https://searchfox.org/mozilla-central/rev/4415bec7a49c50a338167d9c8934527b9cae59d0/dom/localstorage/LSValue.cpp#26-29 [2] https://searchfox.org/mozilla-central/rev/4415bec7a49c50a338167d9c8934527b9cae59d0/dom/localstorage/LSValue.h#97,99
Bug 1681300 Comment 15 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
IIUC, the reason that LocalStroage behaves incorrectly for the cases in comment 6 is that LocalStorage (LSNG) relies on tranforming `nsString` between `nsCString`. The browser test in comment 13 is used to make it easier to constently reproduce the issue. I wrote a gtest in comment 14 to prove if we convert `u"\udfff"` from a UTF16 string to a UTF8 string and then converting it back to the UTF16 string. The contents of the UTF16 strings are different. That means we probaby need to consider changing the code in [1, 2]. [1] https://searchfox.org/mozilla-central/rev/4415bec7a49c50a338167d9c8934527b9cae59d0/dom/localstorage/LSValue.cpp#26-29 [2] https://searchfox.org/mozilla-central/rev/4415bec7a49c50a338167d9c8934527b9cae59d0/dom/localstorage/LSValue.h#97,99