<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>17722</bug_id>
          
          <creation_ts>2008-03-08 03:29:39 -0800</creation_ts>
          <short_desc>HTML5 spec violation: &lt;/&gt;&lt;!doctype html&gt; or &lt;/x&gt;&lt;!doctype html&gt; SHOULD NOT imply standards mode</short_desc>
          <delta_ts>2010-09-16 02:05:27 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert Blaut">webkit</reporter>
          <assigned_to name="Adam Barth">abarth</assigned_to>
          <cc>abarth</cc>
    
    <cc>annevk</cc>
    
    <cc>commit-queue</cc>
    
    <cc>eric</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>73075</commentid>
    <comment_count>0</comment_count>
    <who name="Robert Blaut">webkit</who>
    <bug_when>2008-03-08 03:29:39 -0800</bug_when>
    <thetext>The code: &lt;/&gt;&lt;!doctype html&gt; or &lt;/x&gt;&lt;!doctype html&gt; makes Webkit to render page in standards mode (CSS1Compat). 

According to HTML5 spec: 
&quot;Documents must consist of the following parts, in the given order:
1. Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.
2. Any number of comments and space characters.
3. A DOCTYPE.&quot; 

Only BOM, comments and space characters are allowed before DOCTYPE.

Steps to reproduce:
1) Go to a page: http://software.hixie.ch/utilities/js/live-dom-viewer/?%20%3C%2F%3E%3C!doctype%20html%3E%0A and notice &quot;CSS1Compat&quot; in log section.

Expected result:
BackCompat in log section

Current result:
CSS1Compat in log section</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>260680</commentid>
    <comment_count>1</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-08-05 10:17:43 -0700</bug_when>
    <thetext>The spec mandates that we render this document standards mode.  Our current behavior is correct.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261110</commentid>
    <comment_count>2</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2010-08-05 23:24:12 -0700</bug_when>
    <thetext>As far as I can tell anything but whitespace, comments, and DOCTYPEs throws you out of the &quot;initial&quot; insertion mode and puts the document in standards mode so if this bug still applies with the new parser there is a bug. (And a lack of tests :/)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261111</commentid>
    <comment_count>3</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2010-08-05 23:24:53 -0700</bug_when>
    <thetext>I meant to say puts the document in quirks mode. Argh.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>261119</commentid>
    <comment_count>4</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-08-05 23:33:24 -0700</bug_when>
    <thetext>Ok.  I&apos;ll take another look.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>278578</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-09-13 16:59:09 -0700</bug_when>
    <thetext>Looking now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>278593</commentid>
    <comment_count>6</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-09-13 17:32:16 -0700</bug_when>
    <thetext>Looks like our behavior is correct.  Adding tests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>278595</commentid>
    <comment_count>7</comment_count>
      <attachid>67494</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-09-13 17:38:03 -0700</bug_when>
    <thetext>Created attachment 67494
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>278608</commentid>
    <comment_count>8</comment_count>
      <attachid>67494</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-09-13 18:08:12 -0700</bug_when>
    <thetext>Comment on attachment 67494
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=67494&amp;action=prettypatch

Better to have it say PASS or FAIL, but this is OK.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>279055</commentid>
    <comment_count>9</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-09-14 11:45:28 -0700</bug_when>
    <thetext>PASS/FAIL tests are hard to change latter if we&apos;re intentionally changing behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>279078</commentid>
    <comment_count>10</comment_count>
      <attachid>67494</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-09-14 12:24:15 -0700</bug_when>
    <thetext>Comment on attachment 67494
Patch

Clearing flags on attachment: 67494

Committed r67484: &lt;http://trac.webkit.org/changeset/67484&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>279079</commentid>
    <comment_count>11</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-09-14 12:24:20 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>279388</commentid>
    <comment_count>12</comment_count>
    <who name="Robert Blaut">webkit</who>
    <bug_when>2010-09-14 22:36:15 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; Looks like our behavior is correct.  Adding tests.

Adam, could you explain why the current behavior is correct?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>279434</commentid>
    <comment_count>13</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-09-15 00:32:54 -0700</bug_when>
    <thetext>&gt; Adam, could you explain why the current behavior is correct?

Sure.

&lt;/x&gt;&lt;!doctype html&gt;

This case generates a close tag token for the &lt;/x&gt;, which kicks us out of the initial model, so the doctype doesn&apos;t trigger standards mode.  Hence, quirks.

&lt;/&gt;&lt;!doctype html&gt; or 

This case doesn&apos;t generate any token for &lt;/&gt;.  It just gets eaten by the tokenizer.  That means the first token we see is the doctype, which triggers standards mode.  Hence, standards.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>279979</commentid>
    <comment_count>14</comment_count>
    <who name="Robert Blaut">webkit</who>
    <bug_when>2010-09-16 01:41:36 -0700</bug_when>
    <thetext>(In reply to comment #13)

&gt; &lt;/&gt;&lt;!doctype html&gt; or 
&gt; 
&gt; This case doesn&apos;t generate any token for &lt;/&gt;.  It just gets eaten by the tokenizer.  That means the first token we see is the doctype, which triggers standards mode.  Hence, standards.

Is it correct behavior according HTML5 specification [http://www.w3.org/TR/html5/syntax.html#writing]?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>279983</commentid>
    <comment_count>15</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-09-16 02:05:27 -0700</bug_when>
    <thetext>&gt; Is it correct behavior according HTML5 specification [http://www.w3.org/TR/html5/syntax.html#writing]?

Yes.  Notice the first sentence of that section:

[[
This section only applies to documents, authoring tools, and markup generators. In particular, it does not apply to conformance checkers; conformance checkers must use the requirements given in the next section (&quot;parsing HTML documents&quot;).
]]</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>67494</attachid>
            <date>2010-09-13 17:38:03 -0700</date>
            <delta_ts>2010-09-14 12:24:15 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-17722-20100913173802.patch</filename>
            <type>text/plain</type>
            <size>2705</size>
            <attacher name="Adam Barth">abarth</attacher>
            
              <data encoding="base64">SW5kZXg6IExheW91dFRlc3Rz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rKyBMYXlvdXRUZXN0cy9mYXN0L3BhcnNlci9zdHJhbmdlLWRvY3R5cGUtY29t
cGF0bW9kZS0yLmh0bWwJKHJldmlzaW9uIDApCkBAIC0wLDAgKzEsNiBAQAorPC8+PCFkb2N0eXBl
IGh0bWw+Cis8c2NyaXB0PgoraWYgKHdpbmRvdy5sYXlvdXRUZXN0Q29udHJvbGxlcikKKyAgICBs
YXlvdXRUZXN0Q29udHJvbGxlci5kdW1wQXNUZXh0KCk7Citkb2N1bWVudC53cml0ZShkb2N1bWVu
dC5jb21wYXRNb2RlKTsKKzwvc2NyaXB0Pgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>