Closed Bug 191668 Opened 22 years ago Closed 22 years ago

Tokenizer can fail on <!-

Categories

(Rhino Graveyard :: Core, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: user, Assigned: norrisboyd)

Details

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003
Build Identifier: Rhino CVS from 2003-02-02

Rhino tokenizer violates single character lookahead restriction of
omj.LineBuffer when implementing recognition of HTML comments <!-- . In
particular, LineBuffer assumes that calls to LineBuffer.match will not unread
after successful match, but code to recognize <!-- does exactly that as <! and
<!- are valid sequence of JavaScript operators. 

The following attached test case calls eval on "if (0<!-0) ++j;" prefixed by
increasing sequence of spaces to make sure that at some point <!- occurs on
internal buffer boundary when LineBuffer.unread can not work.



Reproducible: Always

Steps to Reproduce:
Run the test by Rhino shell
Actual Results:  
Exception in thread "main" java.lang.RuntimeException: FAILED ASSERTION
        at org.mozilla.javascript.Context.codeBug(Context.java:2150)
        at org.mozilla.javascript.LineBuffer.unread(LineBuffer.java:116)
        at org.mozilla.javascript.TokenStream.getToken(TokenStream.java:1131)


Expected Results:  
The test should print OK
Attached file Test case
As the bug presents in 1.5R3, its fix should wait until 1.5R4 is released. 
Testcase added to JS testsuite:

      mozilla/js/tests/js1_5/Regress/regress-191668.js

Currently passing in SpiderMonkey, but failing in Rhino as
Igor described above -
Attached patch Patch updateSplinter Review
This is a patch update that integrates LineBuffer into TokenStream and teaches
it to read tokens from String, not only java.io.Reader to avoid constructing
StringReader/TokenStream buffer when evaluating scripts from strings.
Attachment #113398 - Attachment is obsolete: true
I commited the patch
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Verified FIXED.

The above testcase now passes in the Rhino shell. I tested
optimization levels -1, 0, 1, and 9.
Status: RESOLVED → VERIFIED
Targeting as resolved against 1.5R5
Target Milestone: --- → 1.5R5
Fixing wrong milestone assignment
Target Milestone: 1.5R5 → 1.5R4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: