awci / phpquery

Automatically exported from code.google.com/p/phpquery
0 stars 0 forks source link

Text within <script> tag not handled correctly #158

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
HTML placed within a script tag is not handled correctly by phpquery. phpquery 
should treat all text starting after the opening script tag and ending with </ 
as raw text, but it does not.

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

"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."

What steps will reproduce the problem?

> require_once 'phpQuery.php';
> 
> phpQuery::newDocumentHTML(<<<EOF
> <script type="text/x-jquery-tmpl" id="foo">
> <td>test</td>
> </script>
> EOF
> );
> 
> echo '<pre>' . htmlentities((string)pq('#foo'));

What is the expected output? What do you see instead?

Expected:

> <script type="text/x-jquery-tmpl" id="foo">
> <td>test</td>
> </script>

Actual:

> <script type="text/x-jquery-tmpl" id="foo">
> <td>test
> </script>

What version of the product are you using? On what operating system?

phpQuery 0.9.5

Original issue reported on code.google.com by peekaboo.caribou@gmail.com on 25 Oct 2010 at 5:58

GoogleCodeExporter commented 9 years ago
Sorry, ignore that I guess. I see DOMDocument is breaking, here, and for the 
reason outlined in the spec. I guess current browsers are not following this 
part of the spec. Carry on.

Original comment by peekaboo.caribou@gmail.com on 25 Oct 2010 at 6:05