Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Preserve CDATA tags on scripts in XHTML #309

Closed
GoogleCodeExporter opened this issue Apr 6, 2015 · 3 comments
Closed

Preserve CDATA tags on scripts in XHTML #309

GoogleCodeExporter opened this issue Apr 6, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Install Mint (http://www.haveamint.com/)
2. View Mint stats

What is the expected output? What do you see instead?
Each Mint stats panel (page views by day, recent referrer, most popular pages, 
etc.) should make an asynchronous Ajax query and return (and display) those 
statistics. Instead, the page loads and those panels are never populated.

What version of the product are you using (please check X-Mod-Pagespeed header)?
0.9.17.7-716

On what operating system?
CentOS release 5.6

Which version of Apache?
v2.2.3-45

Which MPM?
prefork

Please provide any additional information below, especially a URL or an HTML 
file that exhibits the problem.

Two files are attached—one the HTML returned by Mint with modpagespeed 
enabled (mint-broken.html) and one with it disabled (mint-works.html).

Submitted by request of Joshua Marantz 
(https://twitter.com/#!/jmarantz/status/82493739251138560).

Original issue reported on code.google.com by jaqu...@gmail.com on 19 Jun 2011 at 10:01

Attachments:

@GoogleCodeExporter
Copy link
Author

Looks like we are transforming:


<script type="text/javascript" language="javascript">
// <![CDATA[
SI.Mint.collapse    = true;
window.onload   = function() { SI.Mint.staggerPaneLoading(true); 
SI.Mint.sizePanes(); SI.Mint.onloadScrolls(); };
window.onresize = function() { SI.Mint.sizePanes(); };
// ]]>
</script>

with

<script type="text/javascript" 
language="javascript">SI.Mint.collapse=true;window.onload=function(){SI.Mint.sta
ggerPaneLoading(true);SI.Mint.sizePanes();SI.Mint.onloadScrolls();};window.onres
ize=function(){SI.Mint.sizePanes();};</script>

We have lost the 'CDATA' syntax, which I thought we were pretty careful to put 
in when we ineline scripts.  But evidently we are not retaining it when we 
rewrite scripts.

Original comment by jmara...@google.com on 20 Jun 2011 at 2:32

@GoogleCodeExporter
Copy link
Author

The breakage appears to be due to the use of && in a script block in XHTML.  
Good StackOverflow summary here:

http://stackoverflow.com/questions/66837/when-is-a-cdata-section-necessary-withi
n-a-script-tag

Basically, the script parser worries about different characters (< and & rather 
than </) when parsing a script in the absence of CDATA.  The CDATA puts the 
X[HT]ML parser into "just the characters you see, please" mode.

This is also an issue with scripts we choose to inline into html vs xhtml.

Original comment by jmaes...@google.com on 20 Jun 2011 at 12:12

  • Changed title: Preserve CDATA tags on scripts in XHTML

@GoogleCodeExporter
Copy link
Author

This is now fixed in trunk.

Original comment by jmaes...@google.com on 15 Jul 2011 at 2:01

  • Changed state: Fixed

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

No branches or pull requests

1 participant