Bug Tracker

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#10285 closed bug (fixed)

evalScript rcleanScript replacement fails in IE8

Reported by: james.h.cracknell@… Owned by: james.h.cracknell@…
Priority: high Milestone: 1.8
Component: ajax Version: 1.6.4rc1
Keywords: Cc:
Blocked by: Blocking:

Description

In evalScript the use of the rcleanScript RegExp to wrap XML Comments/CDATA tags with a multiline comment fails because Internet Explorer 8 does not support the $0 backreference. This is actually correct behavior, as the ECMAScript specification explicitly states that n has a non-zero value; the $0 backreference is probably included in most implementations by convention.

'abc'.replace(/a/, '($0)'); // '($0)bc'
'abc'.replace(/a/, '($&)'); // '(a)bc'

The end result is that given an inline script:

<script language="text/javascript"><!--
...
--></script>

the eval'd string looks like:

/*$0*/
...
-->

which bombs when it encounters the XML comment end (as the start is missing).

As a workaround you can insert a single-line comment before the end-comment tag in your inline script:

<script language="text/javascript"><!--
...
//--></script>

so your eval'd script looks like:

/*$0*/
...
//-->

Change History (13)

comment:1 Changed 12 years ago by Rick Waldron

Owner: set to james.h.cracknell@…
Status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 12 years ago by Rick Waldron

Component: unfiledcore
Priority: undecidedlow

comment:3 Changed 12 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

comment:4 Changed 11 years ago by dmethvin

Resolution: invalid
Status: closedreopened

comment:5 Changed 11 years ago by dmethvin

Component: coreajax
Milestone: None1.8
Priority: lowhigh
Status: reopenedopen

Here's a quick repro, you can see the error in the console: http://jsfiddle.net/dmethvin/aBy3L/

Turns out the unit test case we have has a newline before the closing comment, which behaves differently (thanks to our old pal ASI).

comment:6 Changed 11 years ago by dmethvin

Tracing down the problem, it seems to be cause by the commenting out of the closing HTML comment sequence. ///*-->\n*/ gives an error but ///*-->*/ does not. It seems like we can just remove these entirely rather than commenting them out?

comment:7 Changed 11 years ago by jaubourg

err, I fixed this one, didn't I? Or is there something I missed here?

comment:8 Changed 11 years ago by dmethvin

I was getting an error from the commenting, not sure if it's specific to a platform but it was throwing an error in IE9. You can see it in the job here:

http://swarm.jquery.org/job/77

http://swarm.jquery.org/index.php?action=runresults&run_id=938&client_id=5584

Removing the chars rather than commenting them out fixed the problem, but I wasn't sure if there was a reason for leaving them in but commented.

I don't know about the second error in the test there, HTML5 elements.

comment:9 Changed 11 years ago by dmethvin

OBTW, I think the original assertion about the $0 backreference is correct, it should be $& if we're going to keep commenting this out.

comment:10 Changed 11 years ago by jaubourg

#11402 is a duplicate of this ticket.

comment:11 Changed 11 years ago by jaubourg

Resolution: fixed
Status: openclosed

comment:12 Changed 11 years ago by jaubourg

Fixes #10285 (for real this time).

Changeset: 7778c7722239bf5b286e4d8f2740af9abe800c09

comment:13 Changed 11 years ago by gdv.pops@…

I'm still running into this issue. I was using 1.2.6 - with a lot of concerns about the age of the library. I updated to 1.7.2 and began getting this error (80020101). After reading, I updated to 1.8.2 (which completely locked up my opening page...) so I went to 1.8.1 and got the opening page to load, but when the AJAX call is made, I keep getting the error as I did with 1.7.2.

Note: See TracTickets for help on using tickets.