prototypejs / prototype

Prototype JavaScript framework
http://prototypejs.org/
Other
3.54k stars 640 forks source link

evalScripts() function fails with HTML comments #171

Closed jwestbrook closed 9 years ago

jwestbrook commented 10 years ago

previous lighthouse ticket #305 by Dee


The evalScripts() function fails when ISP or security software inserts script into pages.

e.g.:

is inserted by Nortons:

http://service1.symantec.com/SUPPORT/nip.nsf/0/f497e345525fa9e488256dbf007118ac?OpenDocument

Can this be fixed please?

jwestbrook commented 10 years ago

Dee August 26th, 2008 @ 10:30 AM

script inserted:

function SymError()
{
  return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
  return (new Object());
}

window.open = SymWinOpen;
jwestbrook commented 10 years ago

Mark Caudill August 26th, 2008 @ 03:48 PM

This may (or may not) be addressed by this patch: http://prototype.lighthouseapp.com/projects/8886/tickets/299-extractscripts-unreliable-in-ie7#ticket-299-12

jwestbrook commented 10 years ago

Dee August 26th, 2008 @ 08:10 PM

It doesnt look like this is the issue as the start of the

<script language="JavaScript">
jwestbrook commented 10 years ago

Dee August 26th, 2008 @ 06:18 PM

is lower case.

jwestbrook commented 10 years ago

Juriy Zaytsev August 26th, 2008 @ 07:44 PM

Is there actually a space after an opening tag bracket? That would "trip" #evalScripts

jwestbrook commented 10 years ago

Juriy Zaytsev August 26th, 2008 @ 09:37 PM

How exactly does evalScripts fail? The following line seems to evaluate without errors:

<script language="JavaScript">function SymError(){return true;}window.onerror = SymError;var SymRealWinOpen = window.open;function SymWinOpen(url, name, attributes){return (new Object());
jwestbrook commented 10 years ago

Dee August 27th, 2008 @ 11:19 AM

Its without the space, that was a typo. The evalScript throws a 'SyntaxError' which i am catching (however there isnt much more information than that in any of the exception properties) when passing the full html to the evalscript method. I've tried the single line as above, and as you've said i've had it evaluate too. however when passing the full html this still fails. The html i am passing has two instances of the script tag, one with script i've added and the other is the script inserted by Nortons(which is added directly after my script). Do you think its possible the methos is falling over on that?

jwestbrook commented 10 years ago

Juriy Zaytsev August 27th, 2008 @ 01:32 PM

@Dee I wouldn't know which one of the scripts is causing the error ; ) Could you figure it out and paste the appropriate code (that makes evalScripts throw error)

jwestbrook commented 10 years ago

Dee August 27th, 2008 @ 03:26 PM

Apologies, I was hoping someone had come across this issue before, and didnt think to add full details. :) The full details of the scripts on the page are as follows: HTML HEADER NORTON's:

<!--

function SymError()
{
  return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
  return (new Object());
}

window.open = SymWinOpen;

//-->

HTML HEADER MY SCRIPT:

<!--
var stylePath = './styles/';

var errorText = new Object();
errorText.notavailable = 'Test text';

//-->

BOTTOM OF HTML NORTON's:

<!--
var SymRealOnLoad;
var SymRealOnUnload;
function SymOnUnload()
{
  window.open = SymWinOpen;
  if(SymRealOnUnload != null)
     SymRealOnUnload();
}
function SymOnLoad()
{
  if(SymRealOnLoad != null)
     SymRealOnLoad();
  window.open = SymRealWinOpen;
  SymRealOnUnload = window.onunload;
  window.onunload = SymOnUnload;
}
SymRealOnLoad = window.onload;
window.onload = SymOnLoad;
//-->

When Nortons is disabled and only HTML HEADER MY SCRIPT is inlcuded evalScripts seems to work as expected, returning "false". When Nortons is enabled so that all of the three scripts are included i get a SyntaxError returned.

jwestbrook commented 10 years ago

John-David Dalton August 27th, 2008 @ 03:34 PM

Title changed from “evalScripts() function fails to evaluate a page with a SymError() script inserted by Norton ” to “evalScripts() function fails with HTML comments” Tag changed from “ie7” to “ie7, needs_patch, needs_tests” Milestone set to “1.7” This is a known bug with the comments:

<!--- and //-->

The way around it is to use a globalEval solution that writes the code as a textNode of a script element.

jwestbrook commented 10 years ago

Juriy Zaytsev August 27th, 2008 @ 03:52 PM

Tag changed from “ie7” to “ie7, needs_patch, needs_tests” Milestone set to “1.7” @John Why not just make parser account for comments?