Hi All

I've used jQuery a lot over the years, mostly in the joomla CMS
context.  I think I've found a bug in this function:

        // Evalulates a script in a global context
        globalEval: function( data ) {

The problem is that if there is a newline inside of a string literal
(single quoted) in `data`, then the script fails with an "unterminated
string literal" error.  The first thing done to `data` in this
function is this (jQuery 1.2.6):

        data = jQuery.trim( data );

But, this trim function only removes leading and trailing whitespace
using a regex, and not with the s modifier to include newlines
matching the \s character class.

jQuery 1.3.2 omits this call to jQuery.trim, and still exhibits the
"unterminated string literal" error when `data` contains a newline
inside of single quotes.

I don't know what the solution should be for sure, but for my own
purposes I've added this line to globalEval before anything is done
with `data`:

        data = data.replace(/[\r\n\f]+/g, ' ');

It works on data that contains carriage returns, newlines, or form
feed characters, since these (well, at least the newline) don't work
inside single quotes, when evaluated as a javascript.

Love to hear if anyone else has had this problem.

Reply via email to