Closed Bug 288146 Opened 20 years ago Closed 20 years ago

Misparsing of string literal in <script> tag content

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 32618

People

(Reporter: francesco.rizzi, Assigned: bugzilla)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2

See steps to reproduce, but, in short, it seems that if you have the sequence
"</script>" as part of a string literal in a script, that sequence is matched
with the tag that opened the script. This, unless I am mistaken, is incorrect,
since the "</script>" tag is part of a string literal.


Reproducible: Always

Steps to Reproduce:
1. So, here's a simple html document (enclosed in [start] and [end] for clarity):
[start]
<html>
<head>
   <title>Sample Page</title>
<script language="javascript">
var myString = "<html>\n"+
"<head>\n"+
"  <title>Other Page</title>\n"+
"<script language='javascript'>\n"+
"</script>\n"+
"</head>\n"+
"<body>\n"+
"Foooooooooooooooooooooo\n"+
"</body>\n"+
"</html>\n";
</script>
</head>
<body>
Sample Page illustrating bug?<br/>
</body>
</html>
[end]

2. Open this in Firefox 1.02 (or MS IE 6.0.29 for that matter) and get something
bad:
\n"+ "\n"+ "\n"+ "Foooooooooooooooooooooo\n"+ "\n"+ "\n"; Sample Page
illustrating bug?

3. Change the page to the following:
[start]
<html>
<head>
   <title>Sample Page</title>
<script language="javascript">
var myString = "<html>\n"+
"<head>\n"+
"  <title>Other Page</title>\n"+
"<script language='javascript'>\n"+
"</"+"script>\n"+
"</head>\n"+
"<body>\n"+
"Foooooooooooooooooooooo\n"+
"</body>\n"+
"</html>\n";
</script>
</head>
<body>
Sample Page illustrating bug?<br/>
</body>
</html>
[end]

and the page displays correctly.

What I changed is that I broke the string literal
"</script>\n"+
into
"</"+"script>\n"+

So, I'm guessing, the original page was 'badly' parsed (the </script> sequence
in the javascript variable was matched with the opening <script> tag, without
recognizing that </script> was in a string literal).

Unless I'm mistaken, of course.

Actual Results:  
Firefox displayed a page with this text:
\n"+ "\n"+ "\n"+ "Foooooooooooooooooooooo\n"+ "\n"+ "\n"; Sample Page
illustrating bug?


Expected Results:  
Firefox should display a page with this text:
Sample Page illustrating bug?
With Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b2) Gecko/20050329
Firefox/1.0+ and the example, firefox still displays:
\n"+ "\n"+ "\n"+ "Foooooooooooooooooooooo\n"+ "\n"+ "\n"; Sample Page
illustrating bug?
So if this is an issue, it's still present on the trunk.
You will need to break up the string to not have </script> in it.


*** This bug has been marked as a duplicate of 32618 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: