jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ari...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/test parserTests.txt parserTestsOutput.txt
Date Thu, 04 Apr 2002 14:26:58 GMT
arista      02/04/04 06:26:57

  Modified:    standard/src/org/apache/taglibs/standard/lang/jstl
                        ELParser.jj
               standard/src/org/apache/taglibs/standard/lang/jstl/parser
                        ELParser.java ELParserTokenManager.java
               standard/src/org/apache/taglibs/standard/lang/jstl/test
                        parserTests.txt parserTestsOutput.txt
  Added:       standard/src/org/apache/taglibs/standard/lang/jstl/parser
                        SimpleCharStream.java
  Removed:     standard/src/org/apache/taglibs/standard/lang/jstl/parser
                        JavaCharStream.java
  Log:
  Bug 7742 - EL parser should not be interpreting \uXXXX
  
  Fixed by setting JAVA_UNICODE_ESCAPE to false
  
  Revision  Changes    Path
  1.8       +1 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/ELParser.jj
  
  Index: ELParser.jj
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/ELParser.jj,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ELParser.jj	4 Apr 2002 14:01:56 -0000	1.7
  +++ ELParser.jj	4 Apr 2002 14:26:57 -0000	1.8
  @@ -3,7 +3,7 @@
    *****************************************/
   
   options {
  -  JAVA_UNICODE_ESCAPE = true;
  +  JAVA_UNICODE_ESCAPE = false;
     STATIC = false;
   }
   
  
  
  
  1.6       +3 -3      jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/parser/ELParser.java
  
  Index: ELParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/parser/ELParser.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ELParser.java	1 Apr 2002 16:03:33 -0000	1.5
  +++ ELParser.java	4 Apr 2002 14:26:57 -0000	1.6
  @@ -790,7 +790,7 @@
     }
   
     public ELParserTokenManager token_source;
  -  JavaCharStream jj_input_stream;
  +  SimpleCharStream jj_input_stream;
     public Token token, jj_nt;
     private int jj_ntk;
     private int jj_gen;
  @@ -799,7 +799,7 @@
     final private int[] jj_la1_1 = {0x0,0x0,0x0,0x100,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x3e,0xc,0x30,0x3e,0x41,0x41,0x0,0x1fe00,0x0,0x0,0x0,0x1fe00,0xfe00,};
   
     public ELParser(java.io.InputStream stream) {
  -    jj_input_stream = new JavaCharStream(stream, 1, 1);
  +    jj_input_stream = new SimpleCharStream(stream, 1, 1);
       token_source = new ELParserTokenManager(jj_input_stream);
       token = new Token();
       jj_ntk = -1;
  @@ -817,7 +817,7 @@
     }
   
     public ELParser(java.io.Reader stream) {
  -    jj_input_stream = new JavaCharStream(stream, 1, 1);
  +    jj_input_stream = new SimpleCharStream(stream, 1, 1);
       token_source = new ELParserTokenManager(jj_input_stream);
       token = new Token();
       jj_ntk = -1;
  
  
  
  1.6       +20 -28    jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/parser/ELParserTokenManager.java
  
  Index: ELParserTokenManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/parser/ELParserTokenManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ELParserTokenManager.java	4 Apr 2002 14:01:56 -0000	1.5
  +++ ELParserTokenManager.java	4 Apr 2002 14:26:57 -0000	1.6
  @@ -100,9 +100,6 @@
      jjCheckNAdd(jjnextStates[start + 1]);
   }
   static final long[] jjbitVec0 = {
  -   0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
  -};
  -static final long[] jjbitVec2 = {
      0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
   };
   private final int jjMoveNfa_0(int startState, int curPos)
  @@ -184,9 +181,6 @@
         }
         else
         {
  -         int hiByte = (int)(curChar >> 8);
  -         int i1 = hiByte >> 6;
  -         long l1 = 1L << (hiByte & 077);
            int i2 = (curChar & 0xff) >> 6;
            long l2 = 1L << (curChar & 077);
            MatchLoop: do
  @@ -196,7 +190,7 @@
                  case 3:
                  case 0:
                  case 2:
  -                  if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
  +                  if ((jjbitVec0[i2] & l2) == 0L)
                        break;
                     if (kind > 1)
                        kind = 1;
  @@ -696,22 +690,22 @@
      }
      return jjStartNfa_1(9, active0);
   }
  -static final long[] jjbitVec3 = {
  +static final long[] jjbitVec1 = {
      0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
   };
  -static final long[] jjbitVec4 = {
  +static final long[] jjbitVec3 = {
      0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
   };
  -static final long[] jjbitVec5 = {
  +static final long[] jjbitVec4 = {
      0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
   };
  -static final long[] jjbitVec6 = {
  +static final long[] jjbitVec5 = {
      0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
   };
  -static final long[] jjbitVec7 = {
  +static final long[] jjbitVec6 = {
      0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
   };
  -static final long[] jjbitVec8 = {
  +static final long[] jjbitVec7 = {
      0x3fffffffffffL, 0x0L, 0x0L, 0x0L
   };
   private final int jjMoveNfa_1(int startState, int curPos)
  @@ -1037,10 +1031,8 @@
      switch(hiByte)
      {
         case 0:
  -         return ((jjbitVec2[i2] & l2) != 0L);
  +         return ((jjbitVec0[i2] & l2) != 0L);
         default : 
  -         if ((jjbitVec0[i1] & l1) != 0L)
  -            return true;
            return false;
      }
   }
  @@ -1049,17 +1041,17 @@
      switch(hiByte)
      {
         case 0:
  -         return ((jjbitVec4[i2] & l2) != 0L);
  +         return ((jjbitVec3[i2] & l2) != 0L);
         case 48:
  -         return ((jjbitVec5[i2] & l2) != 0L);
  +         return ((jjbitVec4[i2] & l2) != 0L);
         case 49:
  -         return ((jjbitVec6[i2] & l2) != 0L);
  +         return ((jjbitVec5[i2] & l2) != 0L);
         case 51:
  -         return ((jjbitVec7[i2] & l2) != 0L);
  +         return ((jjbitVec6[i2] & l2) != 0L);
         case 61:
  -         return ((jjbitVec8[i2] & l2) != 0L);
  +         return ((jjbitVec7[i2] & l2) != 0L);
         default : 
  -         if ((jjbitVec3[i1] & l1) != 0L)
  +         if ((jjbitVec1[i1] & l1) != 0L)
               return true;
            return false;
      }
  @@ -1088,22 +1080,22 @@
   static final long[] jjtoSkip = {
      0x78L, 
   };
  -private JavaCharStream input_stream;
  +private SimpleCharStream input_stream;
   private final int[] jjrounds = new int[35];
   private final int[] jjstateSet = new int[70];
   protected char curChar;
  -public ELParserTokenManager(JavaCharStream stream)
  +public ELParserTokenManager(SimpleCharStream stream)
   {
  -   if (JavaCharStream.staticFlag)
  +   if (SimpleCharStream.staticFlag)
         throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical
analyzer.");
      input_stream = stream;
   }
  -public ELParserTokenManager(JavaCharStream stream, int lexState)
  +public ELParserTokenManager(SimpleCharStream stream, int lexState)
   {
      this(stream);
      SwitchTo(lexState);
   }
  -public void ReInit(JavaCharStream stream)
  +public void ReInit(SimpleCharStream stream)
   {
      jjmatchedPos = jjnewStateCnt = 0;
      curLexState = defaultLexState;
  @@ -1117,7 +1109,7 @@
      for (i = 35; i-- > 0;)
         jjrounds[i] = 0x80000000;
   }
  -public void ReInit(JavaCharStream stream, int lexState)
  +public void ReInit(SimpleCharStream stream, int lexState)
   {
      ReInit(stream);
      SwitchTo(lexState);
  
  
  
  1.1                  jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/parser/SimpleCharStream.java
  
  Index: SimpleCharStream.java
  ===================================================================
  /* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 2.1 */
  package org.apache.taglibs.standard.lang.jstl.parser;
  
  /**
   * An implementation of interface CharStream, where the stream is assumed to
   * contain only ASCII characters (without unicode processing).
   */
  
  public final class SimpleCharStream
  {
    public static final boolean staticFlag = false;
    int bufsize;
    int available;
    int tokenBegin;
    public int bufpos = -1;
    private int bufline[];
    private int bufcolumn[];
  
    private int column = 0;
    private int line = 1;
  
    private boolean prevCharIsCR = false;
    private boolean prevCharIsLF = false;
  
    private java.io.Reader inputStream;
  
    private char[] buffer;
    private int maxNextCharInd = 0;
    private int inBuf = 0;
  
    private final void ExpandBuff(boolean wrapAround)
    {
       char[] newbuffer = new char[bufsize + 2048];
       int newbufline[] = new int[bufsize + 2048];
       int newbufcolumn[] = new int[bufsize + 2048];
  
       try
       {
          if (wrapAround)
          {
             System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
             System.arraycopy(buffer, 0, newbuffer,
                                               bufsize - tokenBegin, bufpos);
             buffer = newbuffer;
  
             System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
             System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
             bufline = newbufline;
  
             System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
             System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
             bufcolumn = newbufcolumn;
  
             maxNextCharInd = (bufpos += (bufsize - tokenBegin));
          }
          else
          {
             System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
             buffer = newbuffer;
  
             System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
             bufline = newbufline;
  
             System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
             bufcolumn = newbufcolumn;
  
             maxNextCharInd = (bufpos -= tokenBegin);
          }
       }
       catch (Throwable t)
       {
          throw new Error(t.getMessage());
       }
  
  
       bufsize += 2048;
       available = bufsize;
       tokenBegin = 0;
    }
  
    private final void FillBuff() throws java.io.IOException
    {
       if (maxNextCharInd == available)
       {
          if (available == bufsize)
          {
             if (tokenBegin > 2048)
             {
                bufpos = maxNextCharInd = 0;
                available = tokenBegin;
             }
             else if (tokenBegin < 0)
                bufpos = maxNextCharInd = 0;
             else
                ExpandBuff(false);
          }
          else if (available > tokenBegin)
             available = bufsize;
          else if ((tokenBegin - available) < 2048)
             ExpandBuff(true);
          else
             available = tokenBegin;
       }
  
       int i;
       try {
          if ((i = inputStream.read(buffer, maxNextCharInd,
                                      available - maxNextCharInd)) == -1)
          {
             inputStream.close();
             throw new java.io.IOException();
          }
          else
             maxNextCharInd += i;
          return;
       }
       catch(java.io.IOException e) {
          --bufpos;
          backup(0);
          if (tokenBegin == -1)
             tokenBegin = bufpos;
          throw e;
       }
    }
  
    public final char BeginToken() throws java.io.IOException
    {
       tokenBegin = -1;
       char c = readChar();
       tokenBegin = bufpos;
  
       return c;
    }
  
    private final void UpdateLineColumn(char c)
    {
       column++;
  
       if (prevCharIsLF)
       {
          prevCharIsLF = false;
          line += (column = 1);
       }
       else if (prevCharIsCR)
       {
          prevCharIsCR = false;
          if (c == '\n')
          {
             prevCharIsLF = true;
          }
          else
             line += (column = 1);
       }
  
       switch (c)
       {
          case '\r' :
             prevCharIsCR = true;
             break;
          case '\n' :
             prevCharIsLF = true;
             break;
          case '\t' :
             column--;
             column += (8 - (column & 07));
             break;
          default :
             break;
       }
  
       bufline[bufpos] = line;
       bufcolumn[bufpos] = column;
    }
  
    public final char readChar() throws java.io.IOException
    {
       if (inBuf > 0)
       {
          --inBuf;
  
          if (++bufpos == bufsize)
             bufpos = 0;
  
          return buffer[bufpos];
       }
  
       if (++bufpos >= maxNextCharInd)
          FillBuff();
  
       char c = buffer[bufpos];
  
       UpdateLineColumn(c);
       return (c);
    }
  
    /**
     * @deprecated 
     * @see #getEndColumn
     */
  
    public final int getColumn() {
       return bufcolumn[bufpos];
    }
  
    /**
     * @deprecated 
     * @see #getEndLine
     */
  
    public final int getLine() {
       return bufline[bufpos];
    }
  
    public final int getEndColumn() {
       return bufcolumn[bufpos];
    }
  
    public final int getEndLine() {
       return bufline[bufpos];
    }
  
    public final int getBeginColumn() {
       return bufcolumn[tokenBegin];
    }
  
    public final int getBeginLine() {
       return bufline[tokenBegin];
    }
  
    public final void backup(int amount) {
  
      inBuf += amount;
      if ((bufpos -= amount) < 0)
         bufpos += bufsize;
    }
  
    public SimpleCharStream(java.io.Reader dstream, int startline,
    int startcolumn, int buffersize)
    {
      inputStream = dstream;
      line = startline;
      column = startcolumn - 1;
  
      available = bufsize = buffersize;
      buffer = new char[buffersize];
      bufline = new int[buffersize];
      bufcolumn = new int[buffersize];
    }
  
    public SimpleCharStream(java.io.Reader dstream, int startline,
                                                             int startcolumn)
    {
       this(dstream, startline, startcolumn, 4096);
    }
  
    public SimpleCharStream(java.io.Reader dstream)
    {
       this(dstream, 1, 1, 4096);
    }
    public void ReInit(java.io.Reader dstream, int startline,
    int startcolumn, int buffersize)
    {
      inputStream = dstream;
      line = startline;
      column = startcolumn - 1;
  
      if (buffer == null || buffersize != buffer.length)
      {
        available = bufsize = buffersize;
        buffer = new char[buffersize];
        bufline = new int[buffersize];
        bufcolumn = new int[buffersize];
      }
      prevCharIsLF = prevCharIsCR = false;
      tokenBegin = inBuf = maxNextCharInd = 0;
      bufpos = -1;
    }
  
    public void ReInit(java.io.Reader dstream, int startline,
                                                             int startcolumn)
    {
       ReInit(dstream, startline, startcolumn, 4096);
    }
  
    public void ReInit(java.io.Reader dstream)
    {
       ReInit(dstream, 1, 1, 4096);
    }
    public SimpleCharStream(java.io.InputStream dstream, int startline,
    int startcolumn, int buffersize)
    {
       this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
    }
  
    public SimpleCharStream(java.io.InputStream dstream, int startline,
                                                             int startcolumn)
    {
       this(dstream, startline, startcolumn, 4096);
    }
  
    public SimpleCharStream(java.io.InputStream dstream)
    {
       this(dstream, 1, 1, 4096);
    }
  
    public void ReInit(java.io.InputStream dstream, int startline,
                            int startcolumn, int buffersize)
    {
       ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
    }
  
    public void ReInit(java.io.InputStream dstream)
    {
       ReInit(dstream, 1, 1, 4096);
    }
    public void ReInit(java.io.InputStream dstream, int startline,
                                                             int startcolumn)
    {
       ReInit(dstream, startline, startcolumn, 4096);
    }
    public final String GetImage()
    {
       if (bufpos >= tokenBegin)
          return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
       else
          return new String(buffer, tokenBegin, bufsize - tokenBegin) +
                                new String(buffer, 0, bufpos + 1);
    }
  
    public final char[] GetSuffix(int len)
    {
       char[] ret = new char[len];
  
       if ((bufpos + 1) >= len)
          System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
       else
       {
          System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
                                                            len - bufpos - 1);
          System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
       }
  
       return ret;
    }
  
    public void Done()
    {
       buffer = null;
       bufline = null;
       bufcolumn = null;
    }
  
    /**
     * Method to adjust line and column numbers for the start of a token.<BR>
     */
    public void adjustBeginLineColumn(int newLine, int newCol)
    {
       int start = tokenBegin;
       int len;
  
       if (bufpos >= tokenBegin)
       {
          len = bufpos - tokenBegin + inBuf + 1;
       }
       else
       {
          len = bufsize - tokenBegin + bufpos + 1 + inBuf;
       }
  
       int i = 0, j = 0, k = 0;
       int nextColDiff = 0, columnDiff = 0;
  
       while (i < len &&
              bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
       {
          bufline[j] = newLine;
          nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
          bufcolumn[j] = newCol + columnDiff;
          columnDiff = nextColDiff;
          i++;
       } 
  
       if (i < len)
       {
          bufline[j] = newLine++;
          bufcolumn[j] = newCol + columnDiff;
  
          while (i++ < len)
          {
             if (bufline[j = start % bufsize] != bufline[++start % bufsize])
                bufline[j] = newLine++;
             else
                bufline[j] = newLine;
          }
       }
  
       line = bufline[j];
       column = bufcolumn[j];
    }
  
  }
  
  
  
  1.4       +3 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt
  
  Index: parserTests.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- parserTests.txt	4 Apr 2002 14:10:28 -0000	1.3
  +++ parserTests.txt	4 Apr 2002 14:26:57 -0000	1.4
  @@ -87,3 +87,6 @@
   # array accessors of non-integer types
   ${  a ["hello"]."12" [17.5] }
   
  +# making sure unicode escapes are not recognized
  +\u0040
  +"\u0040"
  
  
  
  1.5       +5 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt
  
  Index: parserTestsOutput.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- parserTestsOutput.txt	4 Apr 2002 14:10:28 -0000	1.4
  +++ parserTestsOutput.txt	4 Apr 2002 14:26:57 -0000	1.5
  @@ -152,3 +152,8 @@
   Attribute value: ${  a ["hello"]."12" [17.5] }
   Causes an error: Unable to parse custom action attribute "test" with value "${  a ["hello"]."12"
[17.5] }": encountered ""12"", expected one of ""pageContext", "page", "request", "session",
"application", "param", "params", <IDENTIFIER>"
   
  +# making sure unicode escapes are not recognized
  +Attribute value: \u0040
  +Parses to: \u0040
  +Attribute value: "\u0040"
  +Parses to: "\u0040"
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message