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

Inline js files even if they contain "</script>" #106

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

Inline js files even if they contain "</script>" #106

GoogleCodeExporter opened this issue Apr 6, 2015 · 8 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

1. Turn on inline_javascript
2. Visit http://www.profileheaven.com/forum/forums.html
3. Page not correctly parsed by browser and shows JS to user.

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

(See attached html saves)

","i"))){i++;if(i>=max_iteration){break;}else{text_blocks[text_blocks.length]=_m
atch[1];source_code=source_code.replace(_match[0],'');}}try{if(text_blocks.lengt
h){for(i=0;i 

Is shown inline in the page, functionality doesn't seem to be affected.  
Browser is IE9 Beta.

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

0.9.10.1-244

On what operating system?

CentOS release 5.4 (Final)

Which version of Apache?
Apache/2.2.3

Which MPM?
Standard

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

http://www.profileheaven.com/forum/forums.html




Original issue reported on code.google.com by mark.har...@gmail.com on 20 Nov 2010 at 3:14

Attachments:

@GoogleCodeExporter
Copy link
Author

Thanks for the report; I have reproduced the issue.  I believe the problem is 
that there is a Javascript file that is being inlined and which contains the 
string "</script>"; this is fine in an external Javascript file, but when 
inlined it causes the browser to think that the <script> tag is being closed at 
that point, which is in the middle of the script.  I'll start working on a fix.

Original comment by mdste...@google.com on 24 Nov 2010 at 3:29

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Noticed similar on other pages. Why not wrapping the included javascript in a 
CDATA-tag? As long as the file does not contain the plain sequence "]]>" 
nothing should happen.
In the case it does, try a fallback on xml comment, if the file also has a 
"-->" in it, just don't inline it.

Original comment by Andreas....@gmail.com on 1 Dec 2010 at 10:36

@GoogleCodeExporter
Copy link
Author

With our new impending branch, we are avoiding this bug by skipping the inline 
if the javascript file contains the string "</script>".

I am changing this to an 'enhancement' so we can track the desire to escape 
that string and go ahead and inline it.

Summary was: Incorrect inline_javascript

Original comment by jmara...@google.com on 3 Dec 2010 at 10:13

  • Changed title: Inline js files even if they contain "</script>"
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

Original comment by sligocki@google.com on 3 Dec 2010 at 10:24

  • Added labels: Priority-Low
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

It turns out that many scripts include </script> and can't be inlined, such as 
show_ads.js

We should find a better fix, such as encoding.

Original comment by jkar...@google.com on 24 Oct 2013 at 5:27

  • Added labels: Priority-Medium
  • Removed labels: Priority-Low

@GoogleCodeExporter
Copy link
Author

Original comment by jefftk@google.com on 17 Dec 2013 at 4:22

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

Original comment by jefftk@google.com on 30 Dec 2013 at 5:54

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Original comment by sligocki@google.com on 2 Jan 2014 at 2:52

  • Added labels: Milestone-v31, release-note

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