
Hitting refresh, over and over - NSFW!
- Muttley
- Sheepie Whore

- Posts: 13169
- Joined: Thu Apr 25, 2002 12:30 pm 0
- XBL Gamertag: Mu77ley
- Location: In a maze of twisty passages, all alike.
- Contact:
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O

Muttley's Blog: Rarely updated, occasionally interesting… maybe
RetroRemakes Framework: Open Source BlitzMax Game Framework
MuttMod: My Open Source BlitzMax Modules
RetroRemakes Framework: Open Source BlitzMax Game Framework
MuttMod: My Open Source BlitzMax Modules
- Muttley
- Sheepie Whore

- Posts: 13169
- Joined: Thu Apr 25, 2002 12:30 pm 0
- XBL Gamertag: Mu77ley
- Location: In a maze of twisty passages, all alike.
- Contact:
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
Or maybe even the fact that the first 6 bytes of the file are "GIF89a"Harlequin wrote:Probably because the image's Content-Type is set as 'image/gif' at the server end.Dungeon-Dave wrote:Okay.. how does that work, then?
I mean an animated GIF with a different extension, yet Firefox can identify it as a GIF and thus animate it.
Muttley's Blog: Rarely updated, occasionally interesting… maybe
RetroRemakes Framework: Open Source BlitzMax Game Framework
MuttMod: My Open Source BlitzMax Modules
RetroRemakes Framework: Open Source BlitzMax Game Framework
MuttMod: My Open Source BlitzMax Modules
- WiteWulf
- Sheepie Whore

- Posts: 10125
- Joined: Mon Aug 23, 2004 11:20 am 0
- PSN: WiteWulf
- Location: Loughborough(ish)
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
Sorry, but that photo is right on so many levels it deserves quoting again!Devlin wrote:who is this and where can I get her phone number..oNyx wrote:
:O
:::G:::
PSN: WiteWulf
Switch: SW-3941-2878-7584
Steam: WITEWULF66
PSN: WiteWulf
Switch: SW-3941-2878-7584
Steam: WITEWULF66
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
Magic numbers.Dungeon-Dave wrote:Okay.. how does that work, then?
I mean an animated GIF with a different extension, yet Firefox can identify it as a GIF and thus animate it.
Many file formats start with a so-called "magic number" as the first few bytes, which uniquely identifies the file's format. This is perfectly sensible design, because, well, file extensions can get changed or MIME types can be wrongly set or missing (as the posted image in question demonstrates).
Supplying file format information externally is, indeed, just asking for trouble, as this information could be set wrongly or become divorced from the file, rendering the file useless because it's not known how to interpret it properly. Including the information inside the file itself, with a simple unique "magic number" at the beginning of the file removes that potential problem.
If you fire up Notepad and then drag and drop files into it, then you can see that BMPs all start with "BM", PNGs all start with "xPNG" (where "x" can vary because it's a number identifying the version, not an ASCII character), GIF files start with "GIF" (followed by a version number - e.g. "GIF89a"), JPEGs with the numbers 0xffd8 (which says it's a JPEG) then 0xffe0 (which says that it's in the "JFIF" format) and then the string "JFIF" (which is really a redundancy, as the first two magic numbers already said it was in JFIF format - but I suppose it can be used as a "double-check" or something, or it's there because it's in ASCII and allows a human being to read off that it's in "JFIF" format) and so forth.
Firefox is detecting the "magic number" of a GIF and then interpreting it as a GIF, regardless of what its file extension or MIME type might say.
In that sense, a file extension or MIME type is really just a "strong hint" as to what format the file is in, before it's loaded - but, obviously, if the file itself says "no, really, I'm a GIF" once it's loaded up and you read off the magic number, then Firefox takes the file's word for it, above the (potentially erroneous) filename or MIME type.
(Also, not all file formats do have "magic numbers", unfortunately. So, in those cases, you do have to just depend on the file extension or MIME type being correct, as you've got nothing else to go on. But all the main image types - BMP, GIF, JPG, PNG, etc. - do all use magic numbers in their formats.)
Magic numbers, though, was never a properly standardised thing (and still isn't).
Good file format designers realise they're a useful thing and then include them in their format off their own backs, because it makes sense to do so (and the Firefox developers also realise that if you've got a proper "magic number" then that's the most reliable way of determining format - so where it exists, go with it). But it's a bit of a mess, because some formats don't have them and, even when they are there, they come in all shapes and sizes, as it was never standardised to follow any uniform format.
p.s. Just tried changing the file extensions on some JPGs in Explorer. The thumbnail viewer and "picture and fax viewer" preview thing still showed them perfectly correctly. So even Windows itself does the "magic number" thing internally, when it can. It's only the shell's "file association" thing, which is a bit dumb, in taking the file extension too literally.
"Words ought to be a little wild - for they are assaults of thought on the unthinking."
- John Maynard Keynes
- John Maynard Keynes
- Harlequin
- Baaaaaaa!

- Posts: 6505
- Joined: Wed Jun 05, 2002 4:19 am 0
- Location: London, directly above the centre of the Earth.
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
Well... the MIME type was correctly set for a gif in the above image.KlaxonCow wrote:Many file formats start with a so-called "magic number" as the first few bytes, which uniquely identifies the file's format. This is perfectly sensible design, because, well, file extensions can get changed or MIME types can be wrongly set or missing (as the posted image in question demonstrates).
Firefox ignores the MIME Content-Type header? Would that not be counter to the HTTP standard?KlaxonCow wrote:Firefox is detecting the "magic number" of a GIF and then interpreting it as a GIF, regardless of what its file extension or MIME type might say.
Emoticon and contraction free since... quite a while ago.
- Dungeon-Dave
- Baaaaaa!

- Posts: 3925
- Joined: Thu Aug 04, 2005 12:01 pm 0
- Location: UK
- Contact:
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
I wondered about that.Harlequin wrote:Firefox ignores the MIME Content-Type header? Would that not be counter to the HTTP standard?
Ta for the explanations, KC n Harley. I know about the MIME stuff, just wondered if that overrode the file extension (and thus I could have something malicious with a .html extension but have the webserver identify "application/x-msdownload").
So, it seems, the order of processing is:
- try file extension
- MIME Content-Type overrides this if different
- magic numbers overrides still if the first few bytes identify it as something different..
That right?
Anyroads.. pics...

Singing detective moment:



- WiteWulf
- Sheepie Whore

- Posts: 10125
- Joined: Mon Aug 23, 2004 11:20 am 0
- PSN: WiteWulf
- Location: Loughborough(ish)
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
Oh, and look: she's got a reasonably cure friend, too!

...and large format ftw, she's got a nose-ring

(Here's the full story of the car, btw, no more pics of the girl
http://www.lxforums.com/board/showthread.php?t=197167 )

...and large format ftw, she's got a nose-ring

(Here's the full story of the car, btw, no more pics of the girl
:::G:::
PSN: WiteWulf
Switch: SW-3941-2878-7584
Steam: WITEWULF66
PSN: WiteWulf
Switch: SW-3941-2878-7584
Steam: WITEWULF66
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
I like a nice nose ring 


Justified and Ancient.
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
Kirk and Nurse Chapel! That sly devil.Dungeon-Dave wrote:
More from b3ta:

- Portland
- Baaaaaaa!

- Posts: 8828
- Joined: Thu Apr 06, 2006 8:16 am 0
- Location: Swinton, South Yorkshire
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O

Mr T as Santa
With the first lady on his knee
And I've not drunk enough
Portland 3.0.1.0 public release rolled out
- Gorecki
- Baaaaaaa!

- Posts: 5962
- Joined: Sat Aug 31, 2002 1:39 am 0
- Location: Essex, home of the Boy Racer
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
Cloudane wrote:



Tang Sou!
- Baggypants
- Baaaaaaa!

- Posts: 5328
- Joined: Sun Mar 19, 2006 12:54 pm 0
- Location: Salford(UK);
- Contact:
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O

from my own recent deletion
"The eggs, get them!"
-
anon76235
- Baaaaaaa!

- Posts: 6712
- Joined: Fri Jul 23, 2004 4:52 pm 0
- XBL Gamertag: tyrwmuwyru,tyweiu,
- PSN: r6wsmunwrtyurtmuwrty
- Yahoo Messenger: 567.,uim576eiw65nuw6u
- Location: rtumsrytu,sruyrtu,sytru
Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O
WiteWulf wrote:Sorry, but that photo is right on so many levels it deserves quoting again!Devlin wrote:who is this and where can I get her phone number..oNyx wrote:
:O
FILMINGS STARTED ON GHOSTBUSTERS 3 THEN EH?



