Closed Bug 1241647 Opened 8 years ago Closed 8 years ago

vcard using deprecated nsIFile as newChannel

Categories

(Thunderbird :: Message Reader UI, defect)

defect
Not set
normal

Tracking

(thunderbird47 fixed)

RESOLVED FIXED
Thunderbird 47.0
Tracking Status
thunderbird47 --- fixed

People

(Reporter: rkent, Assigned: mkmelin)

Details

Attachments

(1 file)

While looking for an issue in ExQuilla, I came across a similar issue in mail code. nsIFile can no longer be passed to asyncFetch, but this code does that:

http://mxr.mozilla.org/comm-central/source/mail/components/nsMailDefaultHandler.js#370

367         // A VCard! Be smart and open the "add contact" dialog.
368         let file = cmdLine.resolveFile(uri);
369         if (file.exists() && file.fileSize > 0) {
370           NetUtil.asyncFetch(file, function(inputStream, status) {
371             if (!Components.isSuccessCode(status)) {
372               return;
373             }

I would expect this to generate an assertion in debug builds. This assertion was added circa gecko 42
For testing, give some .vcf file as argument on the command line - that should open the add contact dialog.

This is one of the new supported ways
http://mxr.mozilla.org/comm-central/source/mozilla/netwerk/base/NetUtil.jsm#305
Assignee: nobody → mkmelin+mozilla
Status: NEW → ASSIGNED
Attachment #8711173 - Flags: review?(acelists)
Yes, in a debug build this produces an error:
Error: NS_ERROR_FILE_TARGET_DOES_NOT_EXIST: Component returned failure code: 0x80520006 (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) [nsICommandLine.resolveFile]
Source File: file:///var/SSD/TB-hg/tbird-bin/dist/bin/components/nsMailDefaultHandler.js
Line: 368

And even causes the main TB window to not open.
Actually not, I really had the path to the file wrong.
Am I supposed to see any difference with the patch? I do not see one. If I give correct file, it opens the add contact window (with or without patch). For some invalid paths, it just hangs silently. For some invalid paths it produces the error I pasted.

Or is this just using the newer api but the old one is still working?
aceman: Are you using a debug build? I believe it is still supported in release builds.
Yes, I tried the patch on trunk debug build.
At least in the NetUtil.jsm code it's just deprecated. The old way is still working so it's just about using the newer api.
Comment on attachment 8711173 [details] [diff] [review]
bug1241647_vcard_channel.patch

Review of attachment 8711173 [details] [diff] [review]:
-----------------------------------------------------------------

OK then.

::: mail/components/nsMailDefaultHandler.js
@@ +367,5 @@
>          // A VCard! Be smart and open the "add contact" dialog.
>          let file = cmdLine.resolveFile(uri);
>          if (file.exists() && file.fileSize > 0) {
> +          let uriSpec = Services.io.newFileURI(file).spec;
> +          NetUtil.asyncFetch({uri: uriSpec, loadUsingSystemPrincipal: true}, function(inputStream, status) {

Can you break the line before the "function"? It seems quite long now.
Attachment #8711173 - Flags: review?(acelists) → review+
https://hg.mozilla.org/comm-central/rev/a095c7afeb05 -> FIXED

No need to take this on branches, the old way still works.
Target Milestone: --- → Thunderbird 47.0
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: