The autocomplete attribute and web documents using XHTML: Difference between revisions
| Line 36: | Line 36: | ||
2. The next-best solution would be to persuade the W3C to include the autocomplete attribute in an XHTML module similar to the [http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Legacy Legacy module]. But I think that will never happen. | 2. The next-best solution would be to persuade the W3C to include the autocomplete attribute in an XHTML module similar to the [http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Legacy Legacy module]. But I think that will never happen. | ||
3. More plausibly, we could | 3. More plausibly, we could add browser support for a <code>formhistory</code> attribute in a vendor neutral URI such as <nowiki>http://www.legacymarkup.org/xmlns/formhistory</nowiki>, and implement it in a simple XHTML module. When converting content for serving as HTML, the XSL transformation to HTML would be trivial: | ||
<blockquote><pre> | <blockquote><pre> | ||
| Line 58: | Line 58: | ||
and | and | ||
<blockquote> | <blockquote><code>class="fh enable_form_history"</code></blockquote> | ||
<code>class="fh enable_form_history"</code> | |||
The two variations are necessary because an input might have autocomplete enabled within a form that generally wants autocomplete disabled (thanks to richmoore for pointing that out to me). | The two variations are necessary because an input might have autocomplete enabled within a form that generally wants autocomplete disabled (thanks to richmoore for pointing that out to me). | ||
Revision as of 16:16, 5 August 2006
Background
When Microsoft introduced form AutoComplete to the web with Internet Explorer 5 in 1999, they also "extended" the
form and text and password input elements of HTML 3.2 with an autocomplete attribute which allowed site authors to disable this feature on a case-by-case basis. Gecko-based browsers gained an autocomplete feature in 2000, and by 2001 they too were forced to support the autocomplete attribute (Netscape Devedge: How to Turn Off Form Autocompletion). The primary motivation for the attribute at that time was that banks believed disabling autocomplete was a necessary security measure for the login information on their websites, and would bar from their services browsers that had autocomplete features without support for disabling them.
In practice, disabling autocomplete is not a particularly effective security measure. Even in the days of Internet Explorer 5, any machine could be compromised by keylogging that would of course be undeterred by a mere autocomplete attribute. Thanks to the rise of User-Agent spoofing, it became increasingly difficult to exclude browsers like Opera that support form history but ignore the autocomplete attribute by default (Opera's Settings File Explained). And now that web users increasing edit the content delivered to them from the server to suit their own preferences, circumventing the autocomplete attribute is trivial (Remember Password Bookmarklet) even in Mozilla browsers that claim to support it "perfectly" (Mozilla Developer Center: How To Turn Off Form Autocompletion). Nonetheless, even technical opinion is divided over whether autocomplete offers valuable protection against casual attackers or merely lulls users and web authors into a false sense of security, leaving them vulnerable to more determined assailants.
I don't know of a formal statement of the current attitude of banks towards autocomplete, but I suspect many still believe it to be an important safeguard, notwithstanding the flaws I've just mentioned. As late as November 2004, financial standards bodies like APACS were insisting that sensitive systems make use of the attribute and failure to use it could spell public relations disaster (BBC News: Bank moves to close web loophole). Security consultants like McAfee's Corey Benninger continue to recommend that site owners employ the autocomplete attribute (Developer: Browser Cache: Goodies For Hackers). The developers of the Web Forms 2.0 specification were forced to support the autocomplete attribute (Web Forms 2.0 Working Draft: The autocomplete attribute) even though they do not believe it offers any genuine security benefits (Lachlan Hunt kicking off an epic thread on the subject at the WHATWG mailing list).
In 2004, Kevin Gibb's Google Suggest found a new use for the autocomplete attribute: disabling the browser's autocompletion in order to allow a website's own JavaScript autocompletion to begin with a blank input field. Although it is possible to achieve a similar effect without the attribute, Google has set a precendent and now such non-standard code is churned out by Ajax developers, libraries, and toolsets everywhere. For example, Ruby on Rails's autocomplete helpers use it.
In summary, it seems that despite being non-standard, having known security flaws, being replicable with alternate techniques, and suffering from limited browser support (e.g. ELinks has form history but does not recognize the attribute), autocomplete is here to stay.
The Problem
1. Mainstream web development should be based on common markup based on some sort of standards.
2. When serving content is important to be accurate about what standard you are following (hence need for the Vary HTTP header, MIME types, document types, XML schema, microformats, etc), or the standards themselves become depreciated.
2. The web is gradually transitioning from HTML to XML-based markup, helped by minority browsers that can parse the application/xhtml+xml internet media type correctly.
3. When writing HTML, it is trivial to express the autocomplete attribute using the SGML standard by creating a custom DTD and using that as your doctype. You can create such a DTD by simply adding the following line to the HTML 4.01 DTD:
<!ATTLIST (form|input) autocomplete (on,off) #IMPLIED>
4. The X in XHTML stands for "extensible". But because all elements and attributes are namespaced in XML and the W3C jealously guard their XHTML namespace from extension by others, a site author may not do the same with XHTML-based markup. While it is certainly possible to build a custom XML DTD to include an autocomplete, the act would be meaningless as the W3C have made it clear they would not regard documents extending the XHTML namespace in this way as even using XHTML at all (XHTML Modularization 1.1: Working Draft: Conformance Definition, also see A List Apart: More About Custom DTDs).
5. Therefore there is no current way to use a simple markup attribute to turn off autocompletion when using XHTML.
Possible solutions
Whichever solution is adopted, it is at present only important for Mozilla, KHTML, and WebKit developers to recognize it, as (AFAIK) only browsers based on their engines both correctly parse application/xhtml+xml and claim to allow form history to be disabled by site authors.
1. If we agree that autocomplete is ultimately detrimental to security, the ideal solution would be to persuade the web and financial communities to employ other techniques. Good luck with that.
2. The next-best solution would be to persuade the W3C to include the autocomplete attribute in an XHTML module similar to the Legacy module. But I think that will never happen.
3. More plausibly, we could add browser support for a formhistory attribute in a vendor neutral URI such as http://www.legacymarkup.org/xmlns/formhistory, and implement it in a simple XHTML module. When converting content for serving as HTML, the XSL transformation to HTML would be trivial:
<xsl:template match="@formhistory:formhistory="on""> <!-- Replace with autocomplete attribute --> <xsl:attribute name="autocomplete">on</xsl:attribute> </xsl:template> <xsl:template match="@formhistory:formhistory="off""> <!-- Replace with autocomplete attribute --> <xsl:attribute name="autocomplete">off</xsl:attribute> </xsl:template>
(As a sidenote, if we went down that route, we might like to create a more general http://www.legacymarkup.org/xmlns/legacyml namespace as a retirement home for all sorts of legacy markup that the W3C would, admirably but somewhat impractically, ignore.)
Following the example of XHTML accessibility roles, we could create an associated microformat (Microformats Wiki: Introduction to Microformats) that would overload the class attribute. Accessibility uses "axs" as a delimiter to prevent namespace collision; we could use "fh". So we'd end up supporting:
class="some_css_class some_other_css_class fh disable_form_history"
and
class="fh enable_form_history"
The two variations are necessary because an input might have autocomplete enabled within a form that generally wants autocomplete disabled (thanks to richmoore for pointing that out to me).
When serving the same resource in an HTML representation (e.g. with content negotiation), it would then be possible for an XSL transformation to add the correct autocomplete attribute and leave the class untouched, with something along the lines of:
<xsl:template match="xhtml:input[contains(@class,'disable_form_history')]">
<xsl:element name="{local-name()}">
<!-- Process existing attributes -->
<xsl:apply-templates select="@*"/>
<!-- Add autocomplete attribute -->
<xsl:attribute name="autocomplete">off</xsl:attribute>
</xsl:element>
</xsl:template>
(N.B. This XSL definitely needs testing.)
4. Other alternatives might involve using proprietary extensions, such as XUL/XBL. I suspect any implementation would be dependent on JavaScript, which would not satisfy those using autocomplete for putative security reasons. It would also be inferior to a cross-browser solution. However, such extensions might, however, prove useful for backporting support for namespaced or microformated autocompletion instructions to old versions of browsers, whether Mozilla (with extensions or XUL/XBL), Konqueror (with KParts), or even to Internet Explorer (with HTC). For an inspiring example of what can be achieved with such extensions, have a look at http://w3future.com/weblog/gems/xhtml2.xml, which uses proprietary Opera CSS, XBL, and HTC to mimic XHTML 2 on current user agents.