evalScripts() function fails with HTML comments
Reported by Dee | August 26th, 2008 @ 10:28 AM | in 1.6.1
The evalScripts() function fails when ISP or security software inserts script into pages.
e.g.:
is inserted by Nortons:
http://service1.symantec.com/SUP...
Can this be fixed please?
Comments and changes to this ticket
-

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;
-
Mark Caudill August 26th, 2008 @ 03:48 PM
- → Tag changed from to ie7
This may (or may not) be addressed by this patch: http://prototype.lighthouseapp.c...
-

Dee August 26th, 2008 @ 08:10 PM
It doesnt look like this is the issue as the start of the
<script language="JavaScript"> -

-
Juriy Zaytsev August 26th, 2008 @ 07:44 PM
- → Tag cleared.
Is there actually a space after an opening tag bracket? That would "trip" #evalScripts
-
Juriy Zaytsev August 26th, 2008 @ 09:37 PM
- → Tag changed from to ie7
How exactly does
evalScriptsfail?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());} window.open = SymWinOpen;</script>'.evalScripts(); -

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?
-
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
evalScriptsthrow error) -

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.
-
John-David Dalton August 27th, 2008 @ 03:34 PM
- → Tag changed from ie7 to ie7 needs_patch needs_tests
- → Milestone changed from to 1.6.1
- → Title changed from evalScripts() function fails to evaluate a page with a SymError() script inserted by Norton to evalScripts() function fails with HTML comments
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.
-
Juriy Zaytsev August 27th, 2008 @ 03:52 PM
- → Tag changed from ie7 to ie7 needs_patch needs_tests
- → Milestone changed from to 1.6.1
@John
Why not just make parser account for comments?
-
John-David Dalton August 27th, 2008 @ 05:38 PM
- → State changed from new to bug
-
John-David Dalton October 5th, 2008 @ 06:50 PM
Removed off-topic comments will make a new ticket for String#eval.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
