Hitting refresh, over and over - NSFW!

Inane baanter or words of wisdom - you decide...
Post Reply
User avatar
benedictw
Baaaaaaa!
Baaaaaaa!
Posts: 6012
Joined: Thu Mar 25, 2004 3:44 pm 0
XBL Gamertag: CoderBen
Location: Poole, UK
Contact:

Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O

Post by benedictw »

Image
Gamertag\PSN: CoderBen
User avatar
Muttley
Sheepie Whore
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

Post by Muttley »

Image
Muttley's Blog: Rarely updated, occasionally interesting… maybe
RetroRemakes Framework: Open Source BlitzMax Game Framework
MuttMod: My Open Source BlitzMax Modules
User avatar
Muttley
Sheepie Whore
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

Post by Muttley »

Harlequin wrote:
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.
Probably because the image's Content-Type is set as 'image/gif' at the server end.
Or maybe even the fact that the first 6 bytes of the file are "GIF89a" ;)
Muttley's Blog: Rarely updated, occasionally interesting… maybe
RetroRemakes Framework: Open Source BlitzMax Game Framework
MuttMod: My Open Source BlitzMax Modules
User avatar
WiteWulf
Sheepie Whore
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

Post by WiteWulf »

Devlin wrote:
oNyx wrote:Image

:O
who is this and where can I get her phone number.. ;)
Sorry, but that photo is right on so many levels it deserves quoting again!
:::G:::

PSN: WiteWulf
Switch: SW-3941-2878-7584
Steam: WITEWULF66
User avatar
KlaxonCow
Baaaaaaa!
Baaaaaaa!
Posts: 8447
Joined: Fri Dec 13, 2002 3:46 am 0
Location: A large grassy field.

Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O

Post by KlaxonCow »

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.
Magic numbers.

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
User avatar
Harlequin
Baaaaaaa!
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

Post by Harlequin »

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).
Well... the MIME type was correctly set for a gif in the above image.
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.
Firefox ignores the MIME Content-Type header? Would that not be counter to the HTTP standard?
Emoticon and contraction free since... quite a while ago.
User avatar
Dungeon-Dave
Baaaaaa!
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

Post by Dungeon-Dave »

Harlequin wrote:Firefox ignores the MIME Content-Type header? Would that not be counter to the HTTP standard?
I wondered about that.

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...
Image
Singing detective moment:
Image
Image
Image
User avatar
WiteWulf
Sheepie Whore
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

Post by WiteWulf »

Oh, and look: she's got a reasonably cure friend, too!

Image

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

Image

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

PSN: WiteWulf
Switch: SW-3941-2878-7584
Steam: WITEWULF66
User avatar
Yak
Sheepie Whore
Sheepie Whore
Posts: 20266
Joined: Wed Apr 17, 2002 10:22 am 0
Location: Wales
Contact:

Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O

Post by Yak »

I like a nice nose ring :wub:

Image
Justified and Ancient.
User avatar
Cloudane
Baaaaaaa!
Baaaaaaa!
Posts: 7937
Joined: Wed Jun 15, 2005 6:05 pm 0
Location: VRchat

Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O

Post by Cloudane »

Dungeon-Dave wrote: Image
Kirk and Nurse Chapel! That sly devil.

More from b3ta:
Image
User avatar
Portland
Baaaaaaa!
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

Post by Portland »

Image


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
User avatar
Gorecki
Baaaaaaa!
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

Post by Gorecki »

Cloudane wrote:Image
:lol: Actual tears of laughter here.

Image
Image
Image
Tang Sou!
User avatar
Baggypants
Baaaaaaa!
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

Post by Baggypants »

Image

from my own recent deletion
"The eggs, get them!"
User avatar
ElfQrin
Baaaaaa!
Baaaaaa!
Posts: 4384
Joined: Mon Jul 28, 2003 12:55 pm 0
Location: Italy
Contact:

Re: Hitting refresh, over and over - NO LONGER SAFE FOR WORK! 8O

Post by ElfQrin »

Image
anon76235
Baaaaaaa!
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

Post by anon76235 »

WiteWulf wrote:
Devlin wrote:
oNyx wrote:Image

:O
who is this and where can I get her phone number.. ;)
Sorry, but that photo is right on so many levels it deserves quoting again!

FILMINGS STARTED ON GHOSTBUSTERS 3 THEN EH?
Post Reply