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

Preserve CDATA tags on scripts in XHTML #309

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

Comments

Projects
None yet
1 participant
@GoogleCodeExporter

GoogleCodeExporter commented Apr 6, 2015

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

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

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

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

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

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

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 join this conversation on GitHub. Already have an account? Sign in to comment