Last Comment Bug 712748 - Save Image of JPEG files appends extra ".jpeg" filename extension (e.g. "example.jpg.jpeg")
: Save Image of JPEG files appends extra ".jpeg" filename extension (e.g. "exam...
Status: VERIFIED FIXED
[mentor=cpeterson][lang=java][lang=js]
:
Product: Firefox for Android
Classification: Client Software
Component: General (show other bugs)
: unspecified
: ARM Android
: P4 normal (vote)
: Firefox 20
Assigned To: Ian Patterson
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-21 13:02 PST by Chris Peterson [:cpeterson]
Modified: 2013-01-11 07:04 PST (History)
10 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---
affected
affected
affected
affected
affected
affected
affected
affected
wontfix
verified
+


Attachments
Belongs in 'objdir-droid/dist/bin/chrome/toolkit/content/global/' (39.30 KB, patch)
2012-12-04 09:27 PST, Ian Patterson
no flags Details | Diff | Review
Included a return statement for a urlext try/catch (645 bytes, patch)
2012-12-04 14:00 PST, Ian Patterson
no flags Details | Diff | Review
nsMIMEInfoAndroid::ExtensionExists rewritten to check if requested mimeType exists. (1.33 KB, patch)
2012-12-13 10:39 PST, Ian Patterson
cpeterson: review+
Details | Diff | Review

Description Chris Peterson [:cpeterson] 2011-12-21 13:02:08 PST
STR:
1. Load http://www.jpeg.org (or any website with an embedded .jpg image).
2. Long-press on the big blue image.
3. From the popup menu, select "Save Image".

AR:
The downloaded file's name adds a redundant ".jpeg" filename extension, such as "example.jpg.jpeg".

ER:
The downloaded file should be named "example.jpg".

NOTE:
Downloading .gif and .png files works as expected. The downloaded files do not have redundant filename extensions.
Comment 1 Adrian Tamas (:AdrianT) 2012-05-10 00:50:40 PDT
Issue is still reproducible on Firefox Native 14.0 beta 1 on HTC Desire running Android 2.2
Comment 2 Ian Patterson 2012-12-04 09:27:04 PST
Created attachment 688301 [details] [diff] [review]
Belongs in 'objdir-droid/dist/bin/chrome/toolkit/content/global/'

Added a return statement to line 1009 in an existing try/catch statement (checks if the save target has an extension instead of assigning a new one).
Comment 3 Aaron Train [:aaronmt] 2012-12-04 09:29:42 PST
Hi Ian,

You will need to submit an attachment as a patch (https://developer.mozilla.org/en/docs/Creating_a_patch)
Comment 4 Ian Patterson 2012-12-04 14:00:57 PST
Created attachment 688457 [details] [diff] [review]
Included a return statement for a urlext try/catch

Re-uploading changes in patch form.
Comment 5 Chris Peterson [:cpeterson] 2012-12-04 15:58:30 PST
Comment on attachment 688457 [details] [diff] [review]
Included a return statement for a urlext try/catch

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

Ian, because this bug only affects Android, I think the bug fix will most likely be in Android's js files in mobile-central/mobile/android/base/. The contentAreaUtils.js file is shared with the Firefox desktop browser.

::: toolkit/content/contentAreaUtils.js
@@ +1001,5 @@
>    var urlext;
>    try {
>      url = aURI.QueryInterface(Components.interfaces.nsIURL);
>      urlext = url.fileExtension;
> +    return urlext;

What is the value of the urlext variable? Something like "jpg"? If that extension value existed in mimeInfo, then mimeInfo.extensionExists(urlext) would return true (below) and this function would return urlext.

@@ +1006,5 @@
>    } catch (e) {
>    }
>  
>    if (urlext && mimeInfo && mimeInfo.extensionExists(urlext)) {
>      return urlext;

I suspect that getMIMEInfoForType(aContentType, ext) returned a mimeInfo that does not recognize urlext. Perhaps our Android code is passing a aContentType parameter to the getDefaultExtension() function that does not make sense for .jpg files? Note that this Android bug affects .jpg files, but not .gif or .png files.
Comment 6 :Gavin Sharp [email: gavin@gavinsharp.com] 2012-12-04 16:04:15 PST
Comment on attachment 688457 [details] [diff] [review]
Included a return statement for a urlext try/catch

Looks like we need answers to cpeterson's questions here - cancelling the review request.
Comment 7 Ian Patterson 2012-12-13 10:39:56 PST
Created attachment 691891 [details] [diff] [review]
nsMIMEInfoAndroid::ExtensionExists rewritten to check if requested mimeType exists.
Comment 8 Chris Peterson [:cpeterson] 2012-12-14 11:39:27 PST
Comment on attachment 691891 [details] [diff] [review]
nsMIMEInfoAndroid::ExtensionExists rewritten to check if requested mimeType exists.

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

Looks good to me!
Comment 9 Chris Peterson [:cpeterson] 2012-12-14 11:39:46 PST
Green try test:
https://tbpl.mozilla.org/?tree=Try&rev=411c3e473a4f
Comment 10 Chris Peterson [:cpeterson] 2012-12-14 11:41:25 PST
Thanks, Ian! I checked your patch into mercurial for Firefox 20:

https://hg.mozilla.org/integration/mozilla-inbound/rev/11e520752312
Comment 11 Ryan VanderMeulen [:RyanVM] 2012-12-15 13:30:46 PST
https://hg.mozilla.org/mozilla-central/rev/11e520752312
Comment 12 Ioana Chiorean 2012-12-18 04:38:16 PST
Firefox 20.0a1 (2012-12-17)
Device: Galaxy Nexus
OS: Android 4.1.1

Downloading a picture from jpeg.com it is saved with correct extension. Marking bug as VERIFIED FIXED.

Note You need to log in before you can comment on or make changes to this bug.