<?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>30923</bug_id>
          
          <creation_ts>2009-10-29 13:16:35 -0700</creation_ts>
          <short_desc>When assigning to innerHTML of an element in an XHTML document, HTML entities are not recognized</short_desc>
          <delta_ts>2019-02-06 09:02:32 -0800</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>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jim Driscoll">maus</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>ian</cc>
    
    <cc>janderssn</cc>
    
    <cc>mrowe</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>159031</commentid>
    <comment_count>0</comment_count>
    <who name="Jim Driscoll">maus</who>
    <bug_when>2009-10-29 13:16:35 -0700</bug_when>
    <thetext>The following code:


var element = document.createElement(&quot;div&quot;);
element.innerHTML = &quot;test &amp;nbsp;&quot;;

Throws the following error:

NO_MODIFICATION_ALLOWED_ERR: DOM Exception 7: An attempt was made to modify an object where modifications are not allowed.

This is something of a problem for us (JavaServer Faces Ajax support).

XML entities work fine, but XHTML defined entities, as defined here:
http://www.w3.org/TR/xhtml1/dtds.html#h-A2

Fail.

This is a rather serious problem, and from looking at more than a few JavaScript libraries, it appears that they have not found a workaround.

I tried working around it myself, by creating a contextual fragment, but that just gave a Dom Exception 9 error.

Note that all other tested browsers handle this Just Fine.

Since there is no workaround, I&apos;ve requested this be a P2.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159036</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2009-10-29 13:22:13 -0700</bug_when>
    <thetext>Can you please provide a complete test case that demonstrates the problem?  In my quick test the JavaScript snippet behaved as I expect.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159117</commentid>
    <comment_count>2</comment_count>
    <who name="Joel Andersson">janderssn</who>
    <bug_when>2009-10-29 15:33:29 -0700</bug_when>
    <thetext>The document must be served with the application/xml+xhtml content type for this error to occur.

 1. open http://www.w3c.org (they serve their pages with the application/xml+xhtml content-type)

 2. in the web inspector type document.createElement(&quot;div&quot;).innerHTML = &quot;&amp;nbsp;&quot;;

This raises the NO_MODIFICATION_ALLOWED_ERR error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159119</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2009-10-29 15:38:06 -0700</bug_when>
    <thetext>Ok, so to summarize: When assigning to innerHTML of an element in an XHTML document, HTML entities are not recognized and result in an error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159122</commentid>
    <comment_count>4</comment_count>
      <attachid>42156</attachid>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2009-10-29 15:41:56 -0700</bug_when>
    <thetext>Created attachment 42156
Test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159124</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2009-10-29 15:42:33 -0700</bug_when>
    <thetext>This seems to demonstrate the behavior that you describe.  Note that it also fails in Firefox with a similar error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159126</commentid>
    <comment_count>6</comment_count>
    <who name="Jim Driscoll">maus</who>
    <bug_when>2009-10-29 15:46:47 -0700</bug_when>
    <thetext>Your summary is slightly incorrect in that these are also *XHTML* character entities - and that appears to be the context in which this bug surfaces.

Also, it&apos;s not clear that the document needs to be served with the application/xml+xhtml content type.  It certainly didn&apos;t in my tests.  In my tests, the document was served with a DOCTYPE of XHTML transitional, and a content-type of &quot;text/html&quot; - so it seems that webkit, unlike all other browsers I tested, may have prioritized the DOCTYPE over the content-type.

So you can apparently hit this bug in two different ways.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159127</commentid>
    <comment_count>7</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2009-10-29 15:49:41 -0700</bug_when>
    <thetext>The interesting distinction is that they’re not in the set of predefined XML entities.

Does the test case accurately represent the problem you were seeing?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159129</commentid>
    <comment_count>8</comment_count>
    <who name="Jim Driscoll">maus</who>
    <bug_when>2009-10-29 15:50:29 -0700</bug_when>
    <thetext>Looking at Mark&apos;s example (and noting that as he says it fails in FF also) this may be a quirks mode difference (as I said, I&apos;m serving this as content-type text/html).

Let me run some tests and get back to you in a hour or two.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159174</commentid>
    <comment_count>9</comment_count>
    <who name="Jim Driscoll">maus</who>
    <bug_when>2009-10-29 18:01:51 -0700</bug_when>
    <thetext>Yes, Mark&apos;s testcase completely reflects what I&apos;m seeing.

And it turns out that I was also utterly mistaken in my earlier comment - I am, in fact, serving the file as application/xhtml+xml - the difference was in the weightings that you give to that content type (you prefer it over text/html) vs. what Firefox does (they give equal weighting, which my server tips to text/html).

I apologize for my mistake.  Very embarrassing, for my first filed Webkit bug.

As you point out, you&apos;re bug-compatible with Firefox - you both fail if a user passes an XHTML character entity to an innerHTML of an XHTML document served as xhtml - even an entity that&apos;s perfectly valid per the DTD.  Opera, however, does not fail - it handles assigning entities to XHTML innerHTML just fine.

So, I&apos;d argue that this is a valid bug, though you&apos;re in good company, and I expect to be filing a similar bug against Mozilla shortly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159231</commentid>
    <comment_count>10</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2009-10-29 23:23:51 -0700</bug_when>
    <thetext>We seem to be in perfect agreement with the spec: &lt;http://www.whatwg.org/specs/web-apps/current-work/#xml-fragment-parsing-algorithm&gt;. But maybe the spec should be fixed to make fragment parsing respect target DTD.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159335</commentid>
    <comment_count>11</comment_count>
    <who name="Jim Driscoll">maus</who>
    <bug_when>2009-10-30 10:15:24 -0700</bug_when>
    <thetext>I&apos;m not an XML guy, but isn&apos;t it true that if, as the spec says (from your link): 

declaring the default namespace (if any) that is in scope on that element in the DOM

that that line requires that the entities that are declared in that namespace be respected?

If it doesn&apos;t, then I agree that the spec is broken, because really, you should be able to feed any valid XHTML into the innerHTML property, and have it work.  It shouldn&apos;t fail just because it has a valid XHTML character entity, but work for everything else. 

That&apos;s just dumb.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159353</commentid>
    <comment_count>12</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2009-10-30 10:36:51 -0700</bug_when>
    <thetext>Character entity reference handling is independent of namespaces - if you remove the top DOCTYPE line from your document, then &amp;nbsp; won&apos;t be recognized even in static content.

Note that conforming implementations may not recognize &amp;nbsp; et al. even if a DOCTYPE is provided: &lt;http://www.whatwg.org/specs/web-apps/current-work/#writing-xhtml-documents&gt;. WebKit doesn&apos;t really parse external DTDs, but it knows common XHTML ones and enables XHTML character entity support for those.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159358</commentid>
    <comment_count>13</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2009-10-30 10:42:55 -0700</bug_when>
    <thetext>The editor of HTML5 specification is CC&apos;ed on this bug, so this discussion may be enough to get the issue considered. But you can e-mail the WhatWG working group (or W3C HTML5 working group if you prefer) to be sure that it doesn&apos;t get accidentally overlooked.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>159485</commentid>
    <comment_count>14</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2009-10-30 15:35:04 -0700</bug_when>
    <thetext>What the spec says is intentional -- external DTD parsing is optional in XML, and so entities can&apos;t be relied upon. I would recommend using numeric entities or HTML instead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>278598</commentid>
    <comment_count>15</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-09-13 17:49:32 -0700</bug_when>
    <thetext>We seem to be following the spec and our behavior matches other browsers.  There doesn&apos;t appear to be anything to do here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1502791</commentid>
    <comment_count>16</comment_count>
    <who name="Lucas Forschler">lforschler</who>
    <bug_when>2019-02-06 09:02:32 -0800</bug_when>
    <thetext>Mass moving XML DOM bugs to the &quot;DOM&quot; Component.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>42156</attachid>
            <date>2009-10-29 15:41:56 -0700</date>
            <delta_ts>2009-10-29 15:41:56 -0700</delta_ts>
            <desc>Test case</desc>
            <filename>test.xhtml</filename>
            <type>application/xhtml+xml</type>
            <size>349</size>
            <attacher name="Mark Rowe (bdash)">mrowe</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgU3RyaWN0Ly9FTiIg
Imh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXN0cmljdC5kdGQiPgo8aHRt
bCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCI+CiAgICA8Ym9keT4KICAgICAg
ICA8ZGl2PkZBSUw8L2Rpdj4KICAgICAgICA8c2NyaXB0IHR5cGU9InRleHQvamF2YXNjcmlwdCI+
CiAgICAgICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRzQnlUYWdOYW1lKCdkaXYnKVswXS5pbm5l
ckhUTUwgPSAiUEFceDI2bmJzcDtTUyEiOwogICAgICAgIDwvc2NyaXB0PgogICAgPC9ib2R5Pgo8
L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>