Opened 15 years ago
Closed 15 years ago
#1833 closed bug (invalid)
evaluated script fails with IE if enclosed by an HTML comment
Reported by: | rformato | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.2.2 |
Component: | ajax | Version: | 1.2.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If a script enclosed by an HTML comment is present in a fragment of HTML loaded by ajax of injected in any other way (ie. html(), etc ), IE fails to evaluate it.
The problem is the staring line <!-- of the text inside the script tag.
Here is a simple patch to fix the bug.
globalEval: function( data ) { data = jQuery.trim( data ); if ( data ) { if ( window.execScript ) - window.execScript( data ); + window.execScript( data.replace(/^<!--.*/,"") ); else if ( jQuery.browser.safari ) // safari doesn't provide a synchronous global eval window.setTimeout( data, 0 ); else eval.call( window, data ); } }
Change History (3)
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
Do you have a specific test case of this problem? From what I can tell by the description, you are saying a script that is in an html comment doesn't get evaluated. Isn't that the expected behaviour?
comment:3 Changed 15 years ago by
need: | Review → Test Case |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Looking in to it more, there is a completely different global eval function in SVN (rewritten to fix Safari problems). I'm still not sure what the bug was here. Looking at the patch though this bug no longer makes sense so I'm going to mark it as invalid (since we really didn't fix anything to do with this bug). The new globalEval function creates a <script> tag so any HTML comments would be invalid javascript.
It is quite possible I'm missing the key point so I'd love to see a test case showing the problem. If one is available please reopen the bug with the test case so I can see what's going on.
Thanks.
Sorry, there are some typos in the ticket:
If a script enclosed by an HTML comment is present in a fragment of HTML loaded by ajax or injected in any other way (ie. html(), etc ), IE fails to evaluate it.
The problem is the starting line <!-- of the text inside the script tag.