Closed
Bug 1469499
Opened 6 years ago
Closed 6 years ago
Port Bug 1444329 - Remove nsIScriptableUnicodeConverter::convertFromByteArray
Categories
(Calendar :: General, enhancement)
Calendar
General
Tracking
(Not tracked)
RESOLVED
FIXED
6.4
People
(Reporter: jorgk-bmo, Assigned: darktrojan)
References
Details
Attachments
(3 files)
767 bytes,
patch
|
Details | Diff | Splinter Review | |
59 bytes,
text/x-review-board-request
|
Fallen
:
review+
|
Details |
14.16 KB,
patch
|
Fallen
:
review+
Fallen
:
approval-calendar-beta+
|
Details | Diff | Splinter Review |
https://dxr.mozilla.org/comm-central/search?q=convertFromByteArray&redirect=false
Mostly used in Calendar and causing test failures, see bug 1457087 comment #37.
The use in jsmime.js is "dead" code. The FakeTextDecoder is only used for UTF-7, and that doesn't run
https://dxr.mozilla.org/comm-central/rev/51678c5b0b3edd827c57a70f1c5baf02d44acead/mailnews/mime/src/jsmime.jsm#65
I'm not sure how to handle that.
Reporter | ||
Updated•6 years ago
|
Keywords: leave-open
Reporter | ||
Comment 1•6 years ago
|
||
Reporter | ||
Updated•6 years ago
|
Product: Thunderbird → Calendar
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/5365296a9690
temporarily disable test_ics_parser.js. rs=bustage-fix
Comment hidden (mozreview-request) |
Reporter | ||
Comment 4•6 years ago
|
||
Umm, you've removed the FakeTextDecoder() from JS Mime, unless I'm missing something. We need that to decode UTF-7 in message headers and there are tests covering that.
I believe https://dxr.mozilla.org/comm-central/rev/51678c5b0b3edd827c57a70f1c5baf02d44acead/mailnews/mime/src/jsmime.jsm#62-71 is dead code, since the fake decoder is only used for UTF-7 which is handled above that block.
I suggest to comment-out or remove that block and replace it with a Cu.reportError() of some sort since that code should be reached. That's pretty clear since convertFromByteArray() was removed and we had no test failures in JS Mime.
Assignee | ||
Comment 5•6 years ago
|
||
Oh, I thought you were saying the whole thing was dead code. Oops.
Reporter | ||
Comment 6•6 years ago
|
||
Looking at
https://hg.mozilla.org/try-comm-central/rev/a9e9944f84f883f8bc858f9afa1512bc305572b6#l6.33
I think I gave you the wrong advice. Joshua particularly doesn't like any Mozilla-isms in his "pure JS" library. So it would be better to replace the Cu.reportError() by some throw, like:
throw new Error("FakeTextDecoder: This code should never be reached for " + this.charset);
Sorry about the change of mind.
Reporter | ||
Comment 7•6 years ago
|
||
If I'm not mistaken, you didn't backout https://hg.mozilla.org/comm-central/rev/5365296a9690 for your try run.
Comment hidden (mozreview-request) |
Assignee | ||
Comment 9•6 years ago
|
||
You're right. I've made another try push with the changes, and now I've folded the backout into the patch.
Comment hidden (mozreview-request) |
Assignee | ||
Updated•6 years ago
|
Attachment #8986126 -
Flags: review?(philipp)
Reporter | ||
Comment 11•6 years ago
|
||
Comment on attachment 8986126 [details]
Bug 1469499 - Port Bug 1444329 - Remove nsIScriptableUnicodeConverter::convertFromByteArray
r+ for the JS Mime hunk.
Attachment #8986126 -
Flags: review+
Reporter | ||
Comment 12•6 years ago
|
||
Actually, I've changed my mind again.
Let me explain what's happening here in Joshua's tricky way.
We start with
var RealTextDecoder = TextDecoder;
function FallbackTextDecoder(charset, options) {
try {
return new RealTextDecoder(charset, options);
} catch (e) {
return new FakeTextDecoder(charset, options);
}
}
TextDecoder = FallbackTextDecoder;
Aceman has a patch in bug 1424359 to defuse this trickery.
Basically when calling |new TextDecoder(charset, ...)| elsewhere in JS Mime, either the original TextDecoder is used, or in the catch block, our fake one. The catch should only be entered for UTF-7 which the original decoder doesn't support, and never supported. Prior to bug 1261841 the scriptable Unicode converter could be "enhanced" with more charsets, and TB added UTF-7 (and others?) to it. Today the scriptable Unicode converter is mapped onto encoding_rs and supports exactly what the original TextDecoder supports.
So it's time for some/most/all of this trickery to go.
Looking at your patch again, you need to remove more code:
this._encoder = Cc[
"@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
this._encoder.isInternal = true;
can go.
this._encoder.charset = this.charset;
can be replaced by the same throw we have already.
get encoding() { return this._encoder.charset; },
can go, too.
And then, the comment above those functions needs to be tweaked as well.
Since JS Mime isn't failing after the removal of convertFromByteArray(), I suggest to remove the JS Mime hunk from your patch and let us handle it in bug 1424359.
Reporter | ||
Comment 13•6 years ago
|
||
See attachment 8986641 [details] [diff] [review] for what I mean.
Reporter | ||
Comment 14•6 years ago
|
||
Comment on attachment 8986126 [details]
Bug 1469499 - Port Bug 1444329 - Remove nsIScriptableUnicodeConverter::convertFromByteArray
Sorry about the noise. Lets' deal with the JS Mime part in bug 1424359.
Attachment #8986126 -
Flags: review+
Comment 15•6 years ago
|
||
mozreview-review |
Comment on attachment 8986126 [details]
Bug 1469499 - Port Bug 1444329 - Remove nsIScriptableUnicodeConverter::convertFromByteArray
https://reviewboard.mozilla.org/r/251582/#review258448
r+ with comments considered
::: calendar/base/modules/utils/calProviderUtils.jsm:103
(Diff revision 3)
> * @param {String} aCharset The character set of the bytes, defaults to utf-8
> - * @param {Boolean} aThrow If true, the function will raise an exception on error
> * @return {?String} The string result, or null on error
> */
> - convertByteArray: function(aResult, aResultLength, aCharset, aThrow) {
> - try {
> + convertByteArray: function(aResult, aCharset="utf-8") {
> + return new TextDecoder(aCharset).decode(aResult);
It is highly possible this function is used by addons. I'd suggest to get rid of this function (almost) entirely by using TextDecoder directly in Lightning where before convertByteArray was used. Then keep this function around with the old arguments and a warning using Deprecated.jsm, and call the text decoder as you did.
Note you may have to use Cu.importGlobalProperties to get TextDecoder everywhere.
Attachment #8986126 -
Flags: review?(philipp) → review+
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 18•6 years ago
|
||
Happy with these changes, Philipp?
Comment 19•6 years ago
|
||
mozreview-review |
Comment on attachment 8986126 [details]
Bug 1469499 - Port Bug 1444329 - Remove nsIScriptableUnicodeConverter::convertFromByteArray
https://reviewboard.mozilla.org/r/251582/#review259024
Looks good, one minor comment.
::: calendar/base/modules/utils/calProviderUtils.jsm:106
(Diff revisions 3 - 5)
> + * @param {Boolean} aThrow If true, the function will raise an exception on error
> * @return {?String} The string result, or null on error
> */
> - convertByteArray: function(aResult, aCharset="utf-8") {
> + convertByteArray: function(aResult, aResultLength, aCharset="utf-8", aThrow) {
> + try {
> - return new TextDecoder(aCharset).decode(aResult);
> + return new TextDecoder(aCharset).decode(aResult);
Somewhere here I'd add a Deprecated.warning("The cal.provider.convertByteArray() function has been superseded by the use of TextDecoder", "https://link/to/bug-id"); and import Deprecated.jsm (lazily)
Updated•6 years ago
|
Assignee: nobody → geoff
Updated•6 years ago
|
Status: NEW → ASSIGNED
Comment hidden (mozreview-request) |
Assignee | ||
Updated•6 years ago
|
Keywords: checkin-needed
Reporter | ||
Updated•6 years ago
|
Keywords: leave-open
Comment 21•6 years ago
|
||
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/2135caba7fd1
Port bug 1444329: Replace use of nsIScriptableUnicodeConverter::convertFromByteArray. r=philipp
Reporter | ||
Updated•6 years ago
|
Target Milestone: --- → 6.4
Assignee | ||
Comment 22•6 years ago
|
||
I don't think this works. TextDecoder won't decode an Array, only an ArrayBuffer or ArrayBufferView. The fix is simple, but the fact that no tests broke (other than test_gdata_provider.js which is disabled) is a little worrying.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 23•6 years ago
|
||
Attachment #8988070 -
Flags: review?(philipp)
Comment 24•6 years ago
|
||
Comment on attachment 8988070 [details] [diff] [review]
1469499-textdecoder-1.diff
Review of attachment 8988070 [details] [diff] [review]:
-----------------------------------------------------------------
Yeah, we don't really have provider tests. I have a caldav provider test in my pipeline for the autoconfig bug though.
Attachment #8988070 -
Flags: review?(philipp) → review+
Assignee | ||
Updated•6 years ago
|
Keywords: checkin-needed
Reporter | ||
Updated•6 years ago
|
Attachment #8986126 -
Flags: approval-calendar-beta?(philipp)
Reporter | ||
Comment 25•6 years ago
|
||
Comment on attachment 8988070 [details] [diff] [review]
1469499-textdecoder-1.diff
Needs uplift to TB 62/Cal 6.4 if we want to get Calendar going again at that version.
Attachment #8988070 -
Flags: approval-calendar-beta?(philipp)
Reporter | ||
Comment 26•6 years ago
|
||
Comment on attachment 8986126 [details]
Bug 1469499 - Port Bug 1444329 - Remove nsIScriptableUnicodeConverter::convertFromByteArray
Oops, that's already landed on TB 62.
Attachment #8986126 -
Flags: approval-calendar-beta?(philipp)
Comment 27•6 years ago
|
||
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/bb50c248bd5d
Convert Arrays to Uint8Arrays before trying to decode them with TextDecoder. r=philipp DONTBUILD
Status: REOPENED → RESOLVED
Closed: 6 years ago → 6 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Reporter | ||
Comment 28•6 years ago
|
||
Beta (Calendar 6.4):
https://hg.mozilla.org/releases/comm-beta/rev/dda2d0fbcf09643930a1c08c4409b2781c4b4ff6
Needs to be PUA (post-uplift approval) or you give me the right to approve trivial things myself ;-)
Comment 29•6 years ago
|
||
Comment on attachment 8988070 [details] [diff] [review]
1469499-textdecoder-1.diff
I'm not a fan of uplifting without approval, this was not so urgent that it could not have waited for a+.
Attachment #8988070 -
Flags: approval-calendar-beta?(philipp) → approval-calendar-beta+
Reporter | ||
Comment 30•6 years ago
|
||
Philipp, I think the approval process is there so the module owner gets the chance to approve or reject "risky" uplift requests. This one here was purely administrative, since parts of the bug already landed on TB 62/Cal 6.4.
Also, I land beta stuff in bulk, and right now, I have to manage two beta branches, 60 and 62, which is a mess and highly error prone since there is also only one beta flag and it's therefore quite difficult to find which patch goes to what beta. So I'd like to do things while they are fresh in memory. I also need to update to different branches locally, which is another source of error. So please let me do my work in peace. It appears that you like to contradict me out of principle, but this is really groundless in this case.
As I said, grant me the right to approve trivial stuff.
You need to log in
before you can comment on or make changes to this bug.
Description
•