Live data from Hacker News

This JPEG is also a webpage

lcamtuf.coredump.cx

121–130 of 236 posts

Re: This JPEG is also a webpage

#121
post #99

Can someone explain in simple English how this works?

JPEG images allow comments. The html is stored in the comment. Browsers assume they are reading an HTML file and loads the comment. When the browser thinks it is reading an image, like in an tag, it reads the image ignoring the comment.

Re: This JPEG is also a webpage

#124

Earlier quoted context omitted.

Being flexible about what markup is accepted has meant the web could gain new features and gracefully degrade, and has made it more fault-tolerant. It's not at all a failing. Compare that to JavaScript, which will happily fail if you use new syntax or a missing function, and thus web pages which rely on JS often show up as just a full screen of white when something goes wrong, which it frequently does. That's not to…

> Compare that to JavaScript, which will happily fail if you use new syntax or a missing function, and thus web pages which rely on JS often show up as just a full screen of white when something goes wrong, which it frequently does. Isn't that more due to failure to handle exceptions and display errors to users?

> Isn't that more due to failure to handle exceptions and display errors to users?

You could describe it that way.... or you could describe it as failing to have reasonable default logic for handling faults & gracefully degrade.

Re: This JPEG is also a webpage

#126
post #71

Earlier quoted context omitted.

If it had been made as difficult as possible for enthusiasts learning a markup language to get what was essentially text document to actually display anything, it's probably not too much of an exaggeration to say the World Wide Web wouldn't have existed in its current form. It's not as if many of the web's security holes are related to whether a page displays valid HTML markup or not.

I don't think the assumption is justified that enforcing well-formed HTML documents would have been a significant barrier. To me it actually seems easier to have a few simple and strictly enforced rules than having a more or less random assortment of exception to save a handful of key strokes.

The failure of XHTML Strict suggests otherwise.

Ultimately it's less about saving keystrokes and more about amateur enthusiasts having the opportunity to start with the browser rendering their unformatted document rather than an "Error at line 1" warning, and changes they introduce being considerably less likely to break the entire page

Re: This JPEG is also a webpage

#128

I appreciate the technical trickery in this version, but has it not been possible to do this since at least 1996[1] by having the server serve different files based on the "Accept" http header? [1] https://www.w3.org/Protocols/HTTP/1.0/spec.html#Accept

That's for the initial resource itself, not subsequent asset requests. For instance, an asset request is a separate request on a different domain, such as one for a customer service analytics tag, which is requested without any accept resource type request filter.

So if the initial request comes with "Accept: text/html" then you serve a webpage. The request when linked as img comes as "Accept: /" and you serve an image.

Perhaps caching or other schemes would break this, I'll try to knock up a PoC.

Re: This JPEG is also a webpage

#129
post #27

A testament to one of the worst decisions in computing history - not to fail displaying a web page with an error message in case it is not a valid HTML document.

How would you have prevented huge schisms during the IE push?

In a world where invalid HTML documents aren't rendered at all we could have had the evolution of the format dictated by Microsoft because of their market position.

Re: This JPEG is also a webpage

#130
post #7

That's a chipmunk, not a squirrel.

It's a webpage, not an image.

It's both! That's the whole point - the same sequence of bytes can be interpreted as either an HTML web page or a JPEG image, and the page itself demonstrates both at the same time.
Post reply on HN