JDK-6856823 : Rhino RegExp parser bugs(javax.script)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.script
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2009-07-02
  • Updated: 2011-02-16
  • Resolved: 2011-01-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7Resolved
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
the bug in Rhino. it can not pass when the unescaped word in "[]"group.
such as a base64 filter:  /[a-zA-Z+/=]/; it is valid in ECMAScript,but faild in jdk6.

sun.org.mozilla.javascript.internal/TokenStream.java

line:854

fix to:
    void readRegExp(int startToken)
        throws IOException
    {
        stringBufferTop = 0;
        if (startToken == Token.ASSIGN_DIV) {
            // Miss-scanned /=
            addToString('=');
        } else {
            if (startToken != Token.DIV) Kit.codeBug();
        }
        
        
        int depth = 0;//ADD BY JINDW
        int c;
        while ((c = getChar()) != '/' || depth !=0) {
            if (c == '\n' || c == EOF_CHAR) {
                ungetChar(c);
                throw parser.reportError("msg.unterminated.re.lit");
            }
            /** comment by jindw
            if (c == '\\') {
                addToString(c);
                c = getChar();
            }
            **/
            //ADD BY JINDW BEGIN{
            if(c=='['){
            	depth = 1;
            }else if(c==']'){
            	depth = 0;
            }else if (c == '\\') {
                addToString(c);
                c = getChar();
            }
//            if (c == '\\') {
//                addToString(c);
//                c = getChar();
//            }
            //ADD BY JINDW END}

            addToString(c);
        }
        int reEnd = stringBufferTop;

        while (true) {
            if (matchChar('g'))
                addToString('g');
            else if (matchChar('i'))
                addToString('i');
            else if (matchChar('m'))
                addToString('m');
            else
                break;
        }

        if (isAlpha(peekChar())) {
            throw parser.reportError("msg.invalid.re.flag");
        }

        this.string = new String(stringBuffer, 0, reEnd);
        this.regExpFlags = new String(stringBuffer, reEnd,
                                      stringBufferTop - reEnd);
    }



REPRODUCIBILITY :
This bug can be reproduced always.

Comments
EVALUATION This bug is not reproducible with the latest Rhino (1.7R3) code in jdk7. So, closing this issue as duplicate.
17-01-2011

EVALUATION We plan to update Rhino code in jdk with the latest Rhino code.
17-11-2010