Re: [xml] DOM parser and HTML entities inside the <script> tag



Thanks for the feedback Micheal.

I thought that the first occurrence of </script or </style would be signal the end of the element's content but I guess the W3C had something else in mind.


Best regards,
__
Raymond

On Fri, Jul 20, 2012 at 4:01 AM, Michael Ludwig <milu71 gmx de> wrote:
Raymond Irving schrieb am 18.07.2012 um 23:20 (-0500):
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "
> http://www.w3.org/TR/REC-html40/loose.dtd">
> <html><head><script type="text/_javascript_">
>    var d="&quot;Hello world;&quot; &lt;Test&gt; &amp; ";
>    var h="<p>Some other text</p>";
> </script></head></html>
>
> I get the following result:
>
> script.html:4: HTML parser error : Unexpected end tag : p
>    var h="<p>Some other text</p>";

> IMO, I don't think the parser should be parsing content within the
> <script> tag

I think the following applies:

  Although the STYLE and SCRIPT elements use CDATA for their data
  model, for these elements, CDATA must be handled differently by
  user agents. Markup and entities must be treated as raw text and
  passed to the application as is. The first occurrence of the
  character sequence "</" (end-tag open delimiter) is treated as
  terminating the end of the element's content. In valid
  documents, this would be the end tag for the element.

http://www.w3.org/TR/html401/types.html#type-cdata

Best,

Michael
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
https://mail.gnome.org/mailman/listinfo/xml



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]