MozillaZine

jpeg problem

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
bultaco.rick

User avatar
 
Posts: 8
Joined: April 27th, 2009, 1:47 pm

Post Posted April 27th, 2009, 2:13 pm

I'm assuming this is a bug since the behavior described here is not seen in Safari, Opera, or IE.

I'm running on a Mac - OSX 10.5.6 - with Firefox 3.0.10. The problem was first noticed on 3.0.9 but I thought is was my application so didn't report it.

Simply stated, I have a Ruby/Rails app that loads images. The loaded images are displayed as thumbnails with links to the full sized images. The expected behavior (observed in listed browsers except Firefox) is to click on the thumbnail and have the full size pop up on the same page.

This behavior works only if the filename type is in lower case. If the type is uppercase, the trail given in "Preferences -> Applications -> Content Type === JPEG Picture" is followed.

Here's a snip from Firebug:

Code: Select all
<html>
<head/>
<body>
<h1>Most Wanted</h1>
<a href="/mugshots/0000/0001/DSCN0913.JPG">
<img src="/mugshots/0000/0001/DSCN0913_thumb.JPG?1240866156" alt="Dscn0913_thumb"/>
</a>
<a href="/mugshots/0000/0003/DSCN0925.jpg">
<img src="/mugshots/0000/0003/DSCN0925_thumb.jpg?1240866179" alt="Dscn0925_thumb"/>
</a>
<p>
<a href="/mugshots/new">New shot</a>
</p>
</body>
</html>


In this example, the page displays the two thumbnails - each as a link to its' corresponding image. When selected, the first image-link pops up the "What should Firefox do..." dialog while the second image-link displays the image.

NOTE: the first thumbnail has an uppercase type but it displays correctly.
NOTE: if I change the type of the original image to lowercase an load it into the app it displays correctly.
NOTE: Opera, Safari, and IE do not display this behavior.

thanks in advance,
Rick

LoudNoise
Moderator

User avatar
 
Posts: 39130
Joined: October 18th, 2007, 1:45 pm
Location: Next door to the west

Post Posted April 27th, 2009, 2:18 pm

Moving to Web Development
Post wrangler
β€œIt's tough to make predictions, especially about the future.”
― Yogi Berra

jscher2000

User avatar
 
Posts: 9603
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted April 27th, 2009, 6:59 pm

Generally speaking, Firefox will simply display a JPEG image in the same window by default if the server sends image/jpeg as the file type and does NOT send a content-disposition of attachment. I don't know why your web server would send anything different for .JPG versus .jpg, but that would be the first thing to try to rule out.

bultaco.rick

User avatar
 
Posts: 8
Joined: April 27th, 2009, 1:47 pm

Post Posted April 28th, 2009, 2:38 am

Here is a dump of the database containing four records, one for each of the images and it's related thumbnail. I've inserted some white space between records to make them a little easier to read. You can see from the records that content type is, in all cases, "image/jpeg". Of the four images, the only one which does not display correctly in the full size (parent) image with filename: "DSCN0913.JPG".

>> Mugshot.find(:all)
=> [#<Mugshot id: 1, parent_id: nil, content_type: "image/jpeg", filename: "DSCN0925.jpg", thumbnail: nil, size: 818302, width: 640, height: 479, created_at: "2009-04-28 09:23:24", updated_at: "2009-04-28 09:23:24">,

#<Mugshot id: 2, parent_id: 1, content_type: "image/jpeg", filename: "DSCN0925_thumb.jpg", thumbnail: "thumb", size: 75300, width: 100, height: 75, created_at: "2009-04-28 09:23:25", updated_at: "2009-04-28 09:23:25">,

#<Mugshot id: 3, parent_id: nil, content_type: "image/jpeg", filename: "DSCN0913.JPG", thumbnail: nil, size: 833312, width: 640, height: 479, created_at: "2009-04-28 09:24:41", updated_at: "2009-04-28 09:24:41">,

#<Mugshot id: 4, parent_id: 3, content_type: "image/jpeg", filename: "DSCN0913_thumb.JPG", thumbnail: "thumb", size: 162513, width: 100, height: 75, created_at: "2009-04-28 09:24:41", updated_at: "2009-04-28 09:24:41">]
>>

As I stated in my first post, this condition only exists with the Firefox browser and, I believe, was introduced in a fairly recent version. I'll try installing an older version and see if my memory is correct.

bultaco.rick

User avatar
 
Posts: 8
Joined: April 27th, 2009, 1:47 pm

Post Posted April 28th, 2009, 3:17 am

I've checked firefox v3.0.9 and v2.0.0.9. Both versions demonstrate the problem. I have confirmed that this case sensitivity does not exist on:

Opera v9.64
Safari v3.2.1
IE v5.2 - I know, it's probably the only thing that works on IEv5.2...

Here's what I see at Preferences -> Applications

    JPEG2000 image (image/x-jpeg2000-image) --- Use QuickTime Plug-in 7.6 (in Firefox)
    JPEG2000 image (image/jpeg2000-image) --- Use QuickTime Plug-in 7.6 (in Firefox)
    JPEG2000 image (image/jpeg2000) --- Use QuickTime Plug-in 7.6 (in Firefox)
    JPEG2000 image (image/jp2) --- Use QuickTime Plug-in 7.6 (in Firefox)
    JPEG Picture --- Always Ask

It's curious that .JPG triggers the JPEG Picture action and .jpg triggers the JPEG2000 image action.

BenoitRen

User avatar
 
Posts: 5921
Joined: April 11th, 2004, 10:20 am
Location: Belgium

Post Posted April 28th, 2009, 9:33 am

Have you check if the dialog box that Firefox pops up shows "image/jpeg" as the content type? Your database may know the correct MIME type, but your server may not. On *nix servers, file names (and I suppose file extensions) are case sensitive.

bultaco.rick

User avatar
 
Posts: 8
Joined: April 27th, 2009, 1:47 pm

Post Posted April 28th, 2009, 11:58 am

Not sure what you mean by "the dialog box that Firefox pops up". Can you be more specific?

bultaco.rick

User avatar
 
Posts: 8
Joined: April 27th, 2009, 1:47 pm

Post Posted April 28th, 2009, 12:08 pm

So, if by dialog box you mean the one titled "Opening DSCN0913.JPG", it says:

You have chosen to open
DSCN0913.JPG
which is a: JPEG Picture
from: http://localhost:3000

What should Firefox do with this file?

If, at this point, I select "Open with" and Choose "Firefox.app" the image is downloaded and opened in a new window.
If however, I also select "Do this automatically for files like this from now on.", this does not stick and I am forced to Dialog on every .JPEG Picture.

jscher2000

User avatar
 
Posts: 9603
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted April 28th, 2009, 12:56 pm

Is this an Apache server? Is there already a .htaccess file in the folder with the images? You could check there for anything odd, or try this directive to set the content type and disposition for file names ending with .jpg (case insensitive):

Code: Select all
<FilesMatch "\.(?i:jpg)$">
  ForceType image/jpeg
  Header set Content-Disposition inline
</FilesMatch>

I haven't tested that, it's just a guess based on some stuff on the web. ;) If it works, then the problem is in the server configuration.

bultaco.rick

User avatar
 
Posts: 8
Joined: April 27th, 2009, 1:47 pm

Post Posted April 29th, 2009, 3:46 am

Not Apache - I'm running through Ruby / Rails in development mode. There is no .htaccess visible anywhere on my system.

I have three different servers available, thin, webrick, and mongrel - they all produce the same results. I've changed to a different plugin to handle the image attachment - no common code with the first plugin.

The same results are produced - files with an uppercase type (JPG) are identified in Firefox as JPEG Pictures. Lowercase type triggers one (not sure which) of the image/jpeg2 variants.

Unix file command (which reads the magic numbers at the top of the file) produces:
DSCN0913.JPG: JPEG image data, EXIF standard 2.2
DSCN0925.jpg: JPEG image data, EXIF standard 2.2

Here is the View->Page Source for a page that displays the results of following the href= link:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title>Wankers: show</title>
  <link href="/stylesheets/scaffold.css?1240786686" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<p>
  <b>Name:</b>
  down

  <a href="/system/snaps/2/original/DSCN0925.jpg?1240999195"><img alt="Dscn0925" src="/system/snaps/2/medium/DSCN0925.jpg?1240999195" /></a>

</p>
<a href="/wankers/2/edit">Edit</a> |
<a href="/wankers">Back</a>
</body>
</html>


And the code that doesn't work is:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title>Wankers: show</title>
  <link href="/stylesheets/scaffold.css?1240786686" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<p>
  <b>Name:</b>
  up

  <a href="/system/snaps/1/original/DSCN0913.JPG?1240998428"><img alt="Dscn0913" src="/system/snaps/1/medium/DSCN0913.JPG?1240998428" /></a>

</p>
<a href="/wankers/1/edit">Edit</a> |
<a href="/wankers">Back</a>
</body>
</html>


I'm inclined to think this is a Firefox problem simply because it is not observable on any of the other browsers I have at my disposal. That said, I have also pushed this conversation into the Ruby / Rails group because I cannot say that Firefox is not the only browser doing the right thing with bad data.

What's the way I can snoop the exchange between the server and browser that results from selecting the href= link?

trolly
Moderator

User avatar
 
Posts: 39166
Joined: August 22nd, 2005, 7:25 am

Post Posted April 29th, 2009, 4:22 am

LiveHTTPHeaders addon for example. Or Wireshark.
http://livehttpheaders.mozdev.org/
http://wireshark.org/
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.

bultaco.rick

User avatar
 
Posts: 8
Joined: April 27th, 2009, 1:47 pm

Post Posted April 29th, 2009, 12:14 pm

Live HTTP Headers results:

I've done multiple attachments now of both ".jpg" and ".JPG" files and the results are consitant. Live HTTP reports a content_type of image/jpeg for the ".jpg" image and a type of text/plain for the ".JPG" image. I've included the output here:

Code: Select all
----------------------------------------------------------
http://localhost:3000/mugshots/0000/0001/DSCN0925_thumb.jpg?1241031678

GET /mugshots/0000/0001/DSCN0925_thumb.jpg?1241031678 HTTP/1.1
Host: localhost:3000
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:3000/mugshots
Cookie: _mugshots_session=BAh7CDoPc2Vzc2lvbl9pZCIlN2IwMmNhYWQwY2IwMTQxOTBkNzVmOTg0ZGM2YzM4ZGVJIgpmbGFzaAY6DWVuY29kaW5nIg1VU...
If-Modified-Since: Wed, 29 Apr 2009 19:01:18 GMT
Cache-Control: max-age=0

HTTP/1.x 200 OK
Last-Modified: Wed, 29 Apr 2009 19:01:18 GMT
Content-Type: image/jpeg
Content-Length: 2780
Connection: keep-alive
Server: thin 1.0.0 codename That's What She Said
----------------------------------------------------------
http://localhost:3000/mugshots/0000/0003/DSCN0913_thumb.JPG?1241031709

GET /mugshots/0000/0003/DSCN0913_thumb.JPG?1241031709 HTTP/1.1
Host: localhost:3000
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10
Accept: image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:3000/mugshots
Cookie: _mugshots_session=BAh7CDoPc2Vzc2lvbl9pZCIlN2IwMmNhYWQwY2IwMTQxOTBkNzVmOTg0ZGM2YzM4ZGVJIgpmbGFzaAY6DWVuY29kaW5nIg1VU...
If-Modified-Since: Wed, 29 Apr 2009 19:01:49 GMT
Cache-Control: max-age=0

HTTP/1.x 200 OK
Last-Modified: Wed, 29 Apr 2009 19:01:49 GMT
Content-Type: text/plain
Content-Length: 4812
Connection: keep-alive
Server: thin 1.0.0 codename That's What She Said
----------------------------------------------------------


So, now I'm looking for one piece of confirming information from someone more familiar with Live HTTP than I.

Am I correct in my reading of the log? Does the correspondence exist between ".jpg" and "image/jpeg" as well as between ".JPG" and "text/plain"?
Last edited by trolly on April 29th, 2009, 12:33 pm, edited 1 time in total.
Reason: Shortened cookie value

trolly
Moderator

User avatar
 
Posts: 39166
Joined: August 22nd, 2005, 7:25 am

Post Posted April 29th, 2009, 12:36 pm

bultaco.rick wrote:...
Am I correct in my reading of the log? Does the correspondence exist between ".jpg" and "image/jpeg" as well as between ".JPG" and "text/plain"?
The server treats .jpg as image/jpeg and .JPG as text/plain (mostly because the server does not know the .JPG file extension).
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.

bultaco.rick

User avatar
 
Posts: 8
Joined: April 27th, 2009, 1:47 pm

Post Posted April 29th, 2009, 1:14 pm

So I'm still confused as to why the thumbnail (from end of the href= link) displays correctly for both .jpg and .JPG images while the full size (to end of the href= link) only works for .jpg.

What I do understand is that there's an additional server traversal here and that is the source of the problem. So I guess Firefox is the only browser that looks at the "content_type" value when determining what action to take. I'm not saying that like it's a bad thing, just trying to explain the browser behavior. It won't be the first time you guys stand alone.

Anyway, I'ld like to thank you all for your help with this one. I'm pushing it over the the Ruby / Rails gang and think this issue can be marked as closed on your site.

thanks again,
Rick

trolly
Moderator

User avatar
 
Posts: 39166
Joined: August 22nd, 2005, 7:25 am

Post Posted April 29th, 2009, 1:38 pm

Well, the W3C standard says that the browser should look only on the sent content type. IE does additional content sniffing, which in turn can be used to inject code from manufactured images which are sent with e.g. text/plain.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.

Return to Web Development / Standards Evangelism


Who is online

Users browsing this forum: No registered users and 1 guest