0

Incorrect parsing on JavaScript doubles quotes within single quotes

Hi,

The code

CODE
buffer.push('<img src="', state.suggestions[i].companyIconUrl, '">');


fails with

QUOTE
stdin:625: '<img, state.suggestions[i].companyIconUrl, '">');
^^^^^^
FATAL_ERROR: stdin:625+52 - 626+1: Unclosed string


The parsing of the JavaScript code is incorrect. The double quote, in this context, does not need to be balanced. Using arrays as buffers is a very common idiom to go around IE6's fixed object pool size garbage collection algorithm. The error is also incorrectly reported since the src" part is not HTML escaped.

Jules

by
0 Replies
  • I'll run a few tests on this and then report it up the bug chain if the issue is present.

    Thanks,
    Jon

    QUOTE (Julien @ Jun 1 2009, 09:52 PM) <{POST_SNAPBACK}>
    Hi,

    The code

    CODE
    buffer.push('<img src="', state.suggestions[i].companyIconUrl, '">');


    fails with



    The parsing of the JavaScript code is incorrect. The double quote, in this context, does not need to be balanced. Using arrays as buffers is a very common idiom to go around IE6's fixed object pool size garbage collection algorithm. The error is also incorrectly reported since the src" part is not HTML escaped.

    Jules
    0

Recent Posts

in YAP