Activate your free membership today | Log-in

Tuesday, September 30th, 2008

This Week in HTML 5: Clickjacking

Category: HTML, Standards

Mark Pilgrim, in his latest episode on This Week in HTML 5, got into an interesting topic indeed: clickjacking.

The big news this week is the disclosure of a vulnerability that researchers have dubbed “clickjacking.” To understand it, start with Giorgio Maone’s post, Clickjacking and NoScript. Giorgio is the author of the popular NoScript extension for Firefox. In its default configuration, NoScript protects against this vulnerability on most sites in most situations; you can configure it to defeat the attack entirely, but only at the cost of usability and functionality.

Of course, most web users do not run Firefox, and fewer still run NoScript, so web developers still need to be aware of it. Michal Zalewski’s post, Dealing with UI redress vulnerabilities inherent to the current web, addresses some possible workarounds:

  1. Using Javascript hacks to detect that window.top != window to inhibit rendering, or override window.top.location. These mechanisms work only if Javascript is enabled, however, and are not guaranteed to be reliable or future-safe. If the check is carried on every UI click, performance penalties apply, too. Not to mention, the extra complexity is just counterintuitive and weird.
  2. Requiring non-trivial reauthentication (captcha, password reentry) on all UI actions with any potential for abuse. Although this is acceptable for certain critical operations, doing so every time a person adds Bob as a friend on a social networking site, or deletes a single mail in a webmail system, is very impractical.

Worried yet? Now let’s turn to the question of what browser vendors can do to mitigate the vulnerability. Michal offers several proposals. It is important to realize that none of these proposals have been implemented yet, so don’t go rushing off to your text editor and expecting them to do something useful.

A few suggestions were discussed and one “moves us down a slippery slope towards site security policies for IFRAMEs and embedded content, similar to the Flash security model that allows trusted sites to access cross-domain resources. In practice, Flash crossdomain.xml files have a number of problems, and such an approach would still only cover a fraction of the possible use cases.”

Posted by Dion Almaer at 7:47 am
2 Comments

+++--
3.7 rating from 9 votes

Saturday, September 27th, 2008

HTML 5: Ian Hickson showing you features in browsers today!

Category: Browsers, HTML, Standards

Ian Hickson gave a great presentation at Google where he just sat down, opened up Emacs, and started to build demos on the fly that use HTML 5 features. His goal was to use browsers available today (albeit nightlies and such for some of them) to show progress.... so no future tense!

You can watch the presentation below, but to see the code better I recommend going to the high quality version.

Ian put the finished demos online and you can go to them specifically via:

  1. <video> (00:35)
  2. postMessage() (05:40)
  3. localStorage (15:20)
  4. sessionStorage (21:00)
  5. Drag and Drop API (29:05)
  6. onhashchange (37:30)
  7. Form Controls (40:50)
  8. <canvas> (56:55)
  9. Validation (1:07:20)

It is great to see some of this stuff working, and seeing many of them work in more than one browser. I really like seeing postMessage!

HTML:
  1.  
  2. http://www.whatwg.org/demos/2008-sept/gadget-host/host.html
  3.  
  4.      <iframe src="http://damowmow.com/playground/demos/gadget/gadget.html">
  5.      </iframe>
  6.  
  7.      <p>
  8.       <label>
  9.        Nick:
  10.        <input type="text" name="nick" onkeyup="updateNick(value)"/>
  11.       </label>
  12.      </p>
  13.  
  14.      <script>
  15.       function updateNick(nick) {
  16.         frames[0].postMessage('nick=' + nick,
  17.                     'http://damowmow.com/playground/demos/gadget/gadget.html');
  18.       }
  19.      </script>
  20.  
  21.    http://damowmow.com/playground/demos/gadget/gadget.html
  22.  
  23.      <p>Hello <span id=nick>Sir</span>!</p>
  24.      <script>
  25.        addEventListener('message', function (e) {
  26.          if (e.origin == "http://www.whatwg.org" &&
  27.              e.data.substr(0,5) == "nick=")
  28.            document.getElementById('nick').firstChild.data = e.data.substr(5);
  29.        }, false);
  30.      </script>
  31.  

Posted by Dion Almaer at 7:25 am
9 Comments

++++-
4.3 rating from 17 votes

Thursday, September 25th, 2008

input type=camera to give us a simple way to integrate to Webcams

Category: Browsers, Component, Firefox, HTML, Mozilla

There are a substantial number of iPhone apps that tie into the builtin native components such as the camera.

Brad Lassey has been hacking on Fennec (the Mozilla mobile browser) as well as Firefox itself to integrate with camera phones and Webcams alike:

I wrapped a video tag, image and a few buttons in xbl and bound it to <input type=”camera” />. When a user hits a website using this tag, he or she currently will see a live video preview and a “take photo” button. When the user clicks the button, the photo is grabbed from the camera and shown to the user in the image element. The image element and video element are in a deck element so only one is shown at a time. After the photo is taken, there is a button that reads “Take another photo,” in case the user doesn’t like the one they just took. Once the user is satisfied, this element works like any other form element and the file can be uploaded to a web service.

After talking to a few people this should actually be bound to <input type=”file” accept=”image/png”/>. Also, it needs some UI design both for what it looks like in content and for a configuration dialog. Finally, we’ll need to think about security and make sure no one can snap a photo of you when you’re not looking your best.

I kinda like having an input type="camera" myself, to be more explicit. It would be cool if you can get access to the image as data (e.g. the value is data:......). I love it.

Posted by Dion Almaer at 6:13 am
8 Comments

++---
2.1 rating from 71 votes

HTML Whitelist: Sanitize your markup

Category: HTML, Security

HTML Whitelist is the latest in the "cool little Python Web service thrown up on App Engine" by my good colleague DeWitt Clinton.

It does one thing, and it does it well. You can pass the service HTML and it will return a sanitized version.

For example:

HTML:
  1.  
  2. // original
  3. The <strong>quick</strong> brown fox <script src="http://evil.com"> jumps <kbd>over</kbd> the <em>lazy</em> dog.
  4.  
  5. // converted too
  6. The <strong>quick</strong> brown fox &lt;script src=&quot;http://evil.com&quot;&gt; jumps <kbd>over</kbd> the <em>lazy</em> dog.
  7.  

There are a bunch of options. You can pass in HTML, pass a URL to the content, using JSON and JSONP, and different encoding options.

Posted by Dion Almaer at 2:54 am
7 Comments

+++--
3.1 rating from 9 votes

Wednesday, September 17th, 2008

HTML 5: Welcome WebForms and more

Category: HTML, Standards

In Mark Pilgrim's HTML 5 roundup he shares with us the big news:

... the merging of the Web Forms 2 specification into the HTML 5 specification, and updating it with the collected feedback of the last two years.

For more information on encoding news and such, check out the full roundup.

Posted by Dion Almaer at 5:07 am
4 Comments

++++-
4.8 rating from 55 votes

Wednesday, September 3rd, 2008

Adding Custom Tags To Internet Explorer, The Official Way

Category: Browsers, HTML, IE

There have been some clever tricks to create new custom tags in Internet Explorer, such as the createElement trick. However, I never realized that Internet Explorer itself provides a facility to define new tags in the markup and have them styled, since Internet Explorer 5!

Some details from the MSDN documentation on this feature, titled "Using Custom Tags In Internet Explorer". The trick lies in making sure you namespace things. For example, in the MSDN docs for this feature the example of creating a new JUSTIFY tag is given:


<HTML XMLNS:MY>
<MY:JUSTIFY>
   This paragraph demonstrates sample
   usage of the custom MY:JUSTIFY tag in a document.
   By wrapping the paragraph in start and end
   MY:JUSTIFY tags, the contained
   text is justified within the specified width. Try
   resizing the window to verify that the
   content is justified within a 500-pixel width.
   And don't forget to right-click anywhere on the
   window and "View Source".
</MY:JUSTIFY>

You can even style this with CSS!


<HTML XMLNS:MY>
<STYLE>
@media all {
   MY\:JUSTIFY  { text-align:justify; width:500 }
}
</STYLE>

The docs then go on to discuss applying an Internet Explorer 'behavior' to this custom element to give it expanded abilities:

Custom tags become much more interesting when applied with a DHTML behavior. Introduction to DHTML Behaviors (or behaviors) are applied to elements on a page, the same way styles are, using cascading style sheets (CSS) attributes. More specifically, the proposed CSS behavior attribute allows a Web author to specify the location of the behavior and apply that behavior to an element on a page.

Using DHTML in Internet Explorer 4.0.0, it is possible to create simple animated effects, such as flying text, by manipulating the position of elements on a page over time. Beginning with Internet Explorer 5, this functionality can be encapsulated in a behavior, applied to a custom <InetSDK:FLY> tag, and wrapped around blocks of text on a page. This can be applied to cause text to fly from various directions.

I'm going to do more testing on this functionality today to see how deep it goes, but if true it makes it easier to create browser shims for Internet Explorer for things like SVG, MathML, etc., including HTML 5 (if we namespace the HTML 5 elements, required to get this to work).

The reason I'm looking for an alternative to the createElement trick is I've found that it doesn't work with nested custom tags, which limits its usefulness. For example, I've found the following to not enter the DOM correctly:

HTML:
  1.   <custom_container>
  2.      <custom_child></custom_child>
  3.   </custom_container>
  4. </body>
  5. </html>
  6.  

Posted by Brad Neuberg at 1:30 pm
18 Comments

++---
2.4 rating from 18 votes

Friday, August 22nd, 2008

HTML 5: The event loop, hashchange, and more

Category: HTML

Mark Pilgrim continues to keep us up to date with news in HTML 5 land. This week he talks to us about the birth of the event loop, and the hashchange event.

I saw this just after posting about the cross browser hashchange example by Zach Leatherman. In the future we will see a nice, standard way to do this work:

The other major news this week is the addition of the hashchange event, which occurs when the user clicks an in-page link that goes somewhere else on the same page, or when a script programmatically sets the location.hash property. This is primarily useful for AJAX applications that wish to maintain a history of user actions while remaining on the same page. As a concrete example, executing a search of your messages in GMail takes you to a list of search results, but does not change the URL, just the hash; clicking the Back button takes you back to the previous view within GMail (such as your inbox), again without changing the URL (just the hash). GMail employs some nasty hacks to make this work in all browsers; the hashchange event is designed to make those hacks slightly less nasty. Microsoft Internet Explorer 8 pioneered the hashchange event, and its definition in HTML 5 is designed to match Internet Explorer's behavior.

Defining the event loop is a big deal:

The purpose of defining an event loop is to unify the definition of things that happen asychronously. (I want to avoid saying "events" since that term is already overloaded.) For example, if an image defines an onload callback function, exactly when does it get called? Questions like this are now answered in terms of queueing tasks in the event loop.

Thanks again to Mark for doing the work so we don't have too. After seeing three episodes, it is interesting to see the velocity of changes in the spec. Kudos to the group for that.

Posted by Dion Almaer at 8:23 am
1 Comment

+++--
3.5 rating from 4 votes

Friday, August 15th, 2008

HTML5 Live DOM Validator

Category: HTML

Henri Sivonon has taken Hixie’s Live DOM Viewer, and is now running the Validator.nu HTML Parser within it, using GWT 1.5 RC2, which fixed a bug to do with JavaScript in hosted mode.

Simply open the tool and put in some markup and see the puppy run. Below is an example that I saw on Sam Ruby's blog.

Posted by Dion Almaer at 6:23 am
1 Comment

++++-
4 rating from 8 votes

Thursday, August 14th, 2008

This Week in HTML 5: Navigator standardization, Worker, and more

Category: HTML, Standards

Mark Pilgrim has released his second This Week in HTML 5 episode that covers window.navigator, a new Worker, talk on alt, and more.

Navigator standardization

The navigator attribute of the Window interface must return an instance of the Navigator interface, which represents the identity and state of the user agent (the client), and allows Web pages to register themselves as potential protocol and content handlers.

Currently, HTML 5 defines four properties and two methods:

  • appName
  • appVersion
  • platform
  • userAgent
  • registerProtocolHandler
  • registerContentHandler

This is only a subset of navigator properties and methods that browsers already support. See Navigator Object on Google Doctype for complete browser compatibility information.

More content-language's

Content-Language. No, not the HTTP header, not even the <html lang> attribute, but the <meta> tag! As reported by Henri Sivonen,

It seems that some authoring tools and authors use <meta http-equiv='content-language' content='languagetag'> instead of <html lang='languagetag'>.

This led to revision 2057, which defines the <meta> http-equiv="Content-Language"> directive and its relationship with lang, xml:lang, and the Content-Language HTTP header.

In the continuing saga of the alt attribute, the new syntax for alternate text of auto-generated images (which I covered in last week's episode) has generated some followup discussion. Philip Taylor is concerned that it will increase complexity for authoring tools; others feel the complexity is worth the cost. James Graham suggested a no-text-equivalent attribute; similar proposals have been discussed before and rejected.

Switching to the new Web Workers specification (which I also covered last week), Aaron Boodman (one of the developers of Gears) posted his initial feedback. This kicked off a long discussion and led to the creation of the Worker object.

Posted by Dion Almaer at 11:57 am
1 Comment

++++-
4.2 rating from 5 votes

Thursday, August 7th, 2008

This Week in HTML 5: Mark Pilgrim’s new blog series

Category: HTML

I am really jazzed about the first entry in a new series on HTML 5. Mark Pilgrim (of Python, Greasemonkey, Open Web, writer extraordinaire, and creator of Google Doctype) has started the series This Week in HTML 5 which aims to keep us up to speed on the spec, and progress across the board (what are browsers implementing etc).

In the first episode he discusses the progress with workers, interesting clarification around providing text instead of images, and more.

Anyway, over to Mark:

The biggest news is the birth of the Web Workers draft specification. Quoting the spec, "This specification defines an API that allows Web application authors to spawn background workers running scripts in parallel to their main page. This allows for thread-like operation with message-passing as the coordination mechanism." This is the standardization of the API that Google Gears pioneered last year. See also: initial Workers thread, announcement of new spec, response to Workers feedback.

Also notable this week: even more additions to the Requirements for providing text to act as an alternative for images. 4 new cases were added:

  1. A link containing nothing but an image
  2. A group of images that form a single larger image
  3. An image not intended for the user (such as a "web bug" tracking image)
  4. Text that has been rendered to a graphic for typographical effect

Additionally, the spec now tries to define what authors should do if they know they have an image but don't know what it is. Quoting again from the spec:

If the src attribute is set and the alt attribute is set to a string whose first character is a U+007B LEFT CURLY BRACKET character ({) and whose last character is a U+007D RIGHT CURLY BRACKET character (}), the image is a key part of the content, and there is no textual equivalent of the image available. The string consisting of all the characters between the first and the last character of the value of the alt attribute gives the kind of image (e.g. photo, diagram, user-uploaded image). If that value is the empty string (i.e. the attribute is just "{}"), then even the kind of image being shown is not known.

  • If the image is available, the element represents the image specified by the src attribute.
  • If the image is not available or if the user agent is not configured to display the image, then the user agent should display some sort of indicator that the image is not being rendered, and, if possible, provide to the user the information regarding the kind of image that is (as derived from the alt attribute).

Great to see this series kick into gear, and having Mark keep us in the loop on the very important HTML 5 effort.

Posted by Dion Almaer at 11:39 am
Comment here

+++--
3.8 rating from 13 votes

Wednesday, August 6th, 2008

Introducing HTML into an iframe and getting it back

Category: HTML, JavaScript, Tip

Michael Mahemof is working a lot with TiddlyWiki and posted on how the project injects HTML into an iframe, and then get them out later. This enables you to use the browser parser to do its thing:

JAVASCRIPT:
  1.  
  2. // put it in
  3. var doc = iframe.document;
  4. if (iframe.contentDocument)
  5.   doc = iframe.contentDocument; // For NS6
  6. else if(iframe.contentWindow)
  7.   doc = iframe.contentWindow.document; // For IE5.5 and IE6
  8.  
  9. // Put the content in the iframe
  10. doc.open();
  11. doc.writeln(content);
  12. doc.close();
  13.  
  14. // and then get it out
  15. var storeArea = doc.getElementById("storeArea");
  16.  

Posted by Dion Almaer at 11:07 am
7 Comments

++---
2.8 rating from 34 votes

Friday, July 25th, 2008

HTML 5 Linking all around the horn

Category: HTML, Standards

Eric Meyer has been working on an HTML 5 linking proposal and has put together a demonstration of his proposal.

His linking demo shows how you could put href="..." on paragraphs, table rows, cells, and many other places.

This demo is done with simple JavaScript for now, with the obvious hope that browsers natively support these features in the future.

Posted by Dion Almaer at 7:51 am
11 Comments

+++--
3.9 rating from 14 votes

Wednesday, July 16th, 2008

IE8 HTML 5 Ajax Page Navigations

Category: HTML, IE, Standards

Sharath Udupa, an IE developer at Microsoft has posted on the IE 8 page navigations feature:

In IE8 mode, we provide support for script to update the travel log components (for e.g. back/forward buttons, address bar) to reflect client-side updates to documents. This allows a better user experience where users can navigate back and forth without messing the AJAX application state.

What is interesting here is that even though Sharath said: "adopted in IE8 from HTML5" we have Richard Monson-Haefel (Curl evangelist) saying Ajax is dead RIA walking. This strong conclusion comes from the fact that IE implemented an HTML 5 feature???

The Open Web always has baggage from the fact that there are many parties involved, but the benefits have always made it win out. The browser is the virtual machine of the Web. While Richard thinks that fragmentation can kill Ajax, I see a brighter picture. We have HTML 5 to look at, and browser are innovating in interesting ways. That is a good thing. It pushes us forward.

It is interesting that the articles pushed are on Silverlight using this for its own goals, but Sorry Richard, this doesn't mean people will be learning Curl :)

Posted by Dion Almaer at 7:06 am
2 Comments

+++--
3.8 rating from 19 votes

Monday, July 14th, 2008

HTML 5 data- elements to store private values

Category: HTML

John Resig goes into more detail on the HTML 5 data- elements that gives developers a valid place to store metadata:

This allows you to write valid HTML markup (passing an HTML 5 validator) while, simultaneously, embedding data within your page. A quick example:

HTML:
  1.  
  2. <li class="user" data-name="John Resig" data-city="Boston"
  3.      data-lang="js" data-food="Bacon">
  4.