Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content of script tags without type get wrapped into uncommented CDATA #14

Closed
daaain opened this issue Mar 14, 2012 · 1 comment
Closed

Comments

@daaain
Copy link

daaain commented Mar 14, 2012

Hey,

I have run into a quite worrying bug, seems that if there's a <script> tag without a type parameter – which is perfectly valid in HTML5 – Tidy will enclose the contents into an uncommented CDATA :(

Here's a very simple example which reproduces the error for me with Tidy compiled on Max OS X Lion 10.7.3 using the latest (1st March 2012 – 9412ef6) commit.

Using...

tidy --write-back yes test.html

...on this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">


<head>

</head>

<body class=" x ">
<script>
    try { top.document.domain } catch (e) {
        var f = function() { document.body.innerHTML = ''; }
        setInterval(f,1);
        if (document.body) document.body.unload = f;
    }
</script>



<div id="skip-links">
    <p class="skip-link-p">
        Skip to: 
        <a accesskey="1" class="skip-link" href="#content">content</a>, 
        <a accesskey="2" class="skip-link" href="#nav-links">navigation</a>
    </p>
</div>


</body>
</html>

...results in this:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang=
"en-GB">
<head>
<meta name="generator" content=
"HTML Tidy for Mac OS X https://github.com/w3c/tidy-html5/tree/f2825b9" />
<title></title>
</head>
<body class=" x">
<script>
<![CDATA[
        try { top.document.domain } catch (e) {
                var f = function() { document.body.innerHTML = ''; }
                setInterval(f,1);
                if (document.body) document.body.unload = f;
        }
]]>
</script>
<div id="skip-links">
<p class="skip-link-p">Skip to: <a accesskey="1" class="skip-link"
href="#content">content</a>, <a accesskey="2" class="skip-link"
href="#nav-links">navigation</a></p>
</div>
</body>
</html>
@daaain
Copy link
Author

daaain commented Mar 14, 2012

Added pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant