Add a character type for UTF-8 code units and a UTF-8 string type for UTF-8 strings
Categories
(Core :: MFBT, enhancement, P2)
Tracking
()
People
(Reporter: Waldo, Assigned: Waldo)
References
Details
Attachments
(11 files, 9 obsolete files)
|
2.82 KB,
patch
|
Details | Diff | Splinter Review | |
|
20.91 KB,
patch
|
Details | Diff | Splinter Review | |
|
4.46 KB,
patch
|
Details | Diff | Splinter Review | |
|
12.37 KB,
patch
|
Details | Diff | Splinter Review | |
|
40.34 KB,
patch
|
Details | Diff | Splinter Review | |
|
15.11 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
|
27.55 KB,
patch
|
Details | Diff | Splinter Review | |
|
5.78 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
|
1.63 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
|
18.92 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
|
40.14 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
| Assignee | ||
Comment 1•8 years ago
|
||
| Assignee | ||
Comment 2•8 years ago
|
||
| Assignee | ||
Comment 3•8 years ago
|
||
| Assignee | ||
Comment 4•8 years ago
|
||
| Assignee | ||
Comment 5•8 years ago
|
||
| Assignee | ||
Comment 6•8 years ago
|
||
| Assignee | ||
Comment 7•8 years ago
|
||
| Assignee | ||
Comment 8•8 years ago
|
||
| Assignee | ||
Comment 9•8 years ago
|
||
Comment 10•8 years ago
|
||
Comment 11•8 years ago
|
||
| Assignee | ||
Comment 12•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
| Assignee | ||
Comment 13•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
| Assignee | ||
Comment 14•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
| Assignee | ||
Comment 15•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
| Assignee | ||
Comment 16•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
| Assignee | ||
Comment 17•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
| Assignee | ||
Comment 18•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
| Assignee | ||
Comment 19•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
| Assignee | ||
Comment 20•8 years ago
|
||
| Assignee | ||
Comment 21•8 years ago
|
||
| Assignee | ||
Comment 22•8 years ago
|
||
| Assignee | ||
Comment 23•8 years ago
|
||
Comment 24•8 years ago
|
||
Comment 25•8 years ago
|
||
Comment 26•8 years ago
|
||
Comment 27•8 years ago
|
||
Comment 28•8 years ago
|
||
| Assignee | ||
Comment 29•8 years ago
|
||
Comment 30•8 years ago
|
||
Comment 31•8 years ago
|
||
| Assignee | ||
Comment 32•8 years ago
|
||
Comment 33•8 years ago
|
||
Comment 34•8 years ago
|
||
Comment 35•8 years ago
|
||
Comment 36•8 years ago
|
||
Comment 37•8 years ago
|
||
Comment 38•8 years ago
|
||
Comment 39•8 years ago
|
||
Comment 40•8 years ago
|
||
Comment 41•8 years ago
|
||
| Assignee | ||
Comment 42•8 years ago
|
||
Comment 43•8 years ago
|
||
Comment 44•8 years ago
|
||
| Assignee | ||
Comment 45•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
Comment 46•8 years ago
|
||
Comment 47•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
| Assignee | ||
Comment 48•8 years ago
|
||
Comment 49•8 years ago
|
||
| bugherder | ||
| Assignee | ||
Comment 50•8 years ago
|
||
Comment 51•8 years ago
|
||
Comment 52•8 years ago
|
||
Comment 53•8 years ago
|
||
| bugherder | ||
Comment 54•8 years ago
|
||
Comment 55•8 years ago
|
||
Comment 56•7 years ago
|
||
The leave-open keyword is there and there is no activity for 6 months.
:froydnj, maybe it's time to close this bug?
Comment 57•7 years ago
|
||
(In reply to Release mgmt bot [:sylvestre / :calixte] from comment #56)
The leave-open keyword is there and there is no activity for 6 months.
:froydnj, maybe it's time to close this bug?
No, there is still work to be done here.
Comment 58•7 years ago
|
||
The leave-open keyword is there and there is no activity for 6 months.
:froydnj, maybe it's time to close this bug?
Comment 59•7 years ago
|
||
(In reply to Release mgmt bot [:sylvestre / :calixte / :marco for bugbug] from comment #58)
The leave-open keyword is there and there is no activity for 6 months.
:froydnj, maybe it's time to close this bug?
Still a valid bug.
Comment 60•6 years ago
|
||
The leave-open keyword is there and there is no activity for 6 months.
:Waldo, maybe it's time to close this bug?
| Assignee | ||
Comment 61•6 years ago
|
||
At this point...yeah, this probably ought be closed.
mozilla::Utf8Unit as already landed is a useful thing, distinguishing UTF-8-accepting overloads from those accepting just Latin-1 or ASCII or some other encoding.
But while the container and iterator stuff here is moderately nice and all...the extra ownership stuff turns out to be somewhat tedious, for the purpose of JS tokenizing it's not truly needed.
Moreover, C++20 introduces a new char8_t type, and u"foo" will be an array of char8_t. So UTF-8 literals will have a distinct UTF-8-specific type, for template parameter and overload purposes char8_ will be distinct from char or unsigned char (i.e. JS::Latin1Char), and we will get the typed clarity of mozilla::Utf8Unit that we want. And at that point bog-standard containers and iterators (e.g. const char8_t*) will be good enough. And mozilla::Utf8Unit can be replaced/removed.
So this has had its day in the sun, what's landed is adequate, and we can close this.
(In reply to Henri Sivonen (:hsivonen) from comment #54)
Are there use cases for the customizable error notifications beyond being
able to emit different error messages in the different cases? Is it truly
important to emit different error messages for different kinds of UTF-8
errors?
Bug 1546442 comment 13 is a demonstration of a case where it was extremely helpful to have different error messages for this. As an extra bit of polish, those different error messages including the particular offending byte values. Having good errors for this meant when relevant people looked at that bug they -- not even me as domain-expert SpiderMonkey hacker! -- could immediately say garbage had been passed. And because I went to special effort to include byte values in the error message, the 0xE5 in that case provided a poison value for relevant code searching.
It isn't hard to imagine that sort of thing arising again in the future. It could arise again for us as embedder. Web cases are already validated (...or not, if an implementation bug like possibly bug 1546442 happens -- we're still not sure what's up in that bug). But we have non-web users, for example various C++ callers of mozIJSSubScriptLoader.loadSubScript, that pass in non-validated content. And it could arise for other embedders who don't have the web's pre-validated restrictions.
Would it work for SpiderMonkey if we moved the simpler
UTF8CharEnumerator::NextChar() API to MFBT?
https://hg.mozilla.org/mozilla-central/file/8546719c58dc/xpcom/string/
nsUTF8Utils.h#l92
Doesn't give us the same error messages, and as explained above these error messages are demonstrably valuable.
Note that UTF8CharEnumerator::NextChar() generates the number of errors
required by the WHATWG Encoding Standard and recommended by the Unicode
standard. I didn't review mfbt/Utf8.h properly for spec compliance, but the
explicit check for non-shortest forms strongly hints at its behavior perhaps
not being the behavior required by the WHATWG Encoding Standard and
recommended by Unicode, since the WHATWG-required behavior arises best by
pattern-matching the bytes to Table 3-7 from the Unicode standard and not
checking the the scalar value after computing it.
I double-checked the WHATWG algorithm against the one we have, and it is identical to the Utf8.h algorithm. The particular byte-matching that is performed there, in baroque state-machine byte-at-a-time fashion, exactly replicates minimum-value (for code points that are 1, 2, 3, or 4 code units in length), maximum-value (relevant for code points that are 3 and 4 units in length), and no-surrogate (the lead byte of a surrogate is 0xED and the subsequent byte would have to be 0xA0 or greater, but the UTF-8 upper boundary excludes that case and only that case) restrictions enforced by that code. And as the spec notes, "other algorithms that achieve the same result are fine, even encouraged".
| Assignee | ||
Updated•6 years ago
|
Updated•9 months ago
|
Updated•9 months ago
|
Updated•9 months ago
|
Description
•