cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java

2004-11-19 Thread yoavs
yoavs   2004/11/19 07:17:41

  Modified:webapps/docs Tag: TOMCAT_5_0 changelog.xml
   jasper2/src/share/org/apache/jasper/compiler Tag: TOMCAT_5_0
JspReader.java
  Log:
  Bugzilla 29866: JspReader#skipUntil may try to read beyond the end of the file
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.70.2.79 +3 -0  jakarta-tomcat-catalina/webapps/docs/changelog.xml
  
  Index: changelog.xml
  ===
  RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v
  retrieving revision 1.70.2.78
  retrieving revision 1.70.2.79
  diff -u -r1.70.2.78 -r1.70.2.79
  --- changelog.xml 19 Nov 2004 15:01:34 -  1.70.2.78
  +++ changelog.xml 19 Nov 2004 15:17:40 -  1.70.2.79
  @@ -95,6 +95,9 @@
 update 
   Updated JspC usage messages to include recently added configurable 
parameters. (yoavs) 
 /update 
  +  fix
  +bug29866/bug: JspReader#skipUntil may try to read beyond the end 
of the file. (yoavs)
  +  /fix
   /changelog
 /subsection
   
  
  
  
  No   revision
  No   revision
  1.20.2.2  +9 -2  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.20.2.1
  retrieving revision 1.20.2.2
  diff -u -r1.20.2.1 -r1.20.2.2
  --- JspReader.java10 Aug 2004 23:33:02 -  1.20.2.1
  +++ JspReader.java19 Nov 2004 15:17:40 -  1.20.2.2
  @@ -160,7 +160,10 @@
return caw.toString();
   }
   
  -int peekChar() {
  +int peekChar() throws JasperException { 
  +if (!hasMoreInput()) 
  +return -1; 
  +
return current.stream[current.cursor];
   }
   
  @@ -352,7 +355,7 @@
return ret;
   }
   
  -final boolean isSpace() {
  +final boolean isSpace() throws JasperException {
   // Note: If this logic changes, also update Node.TemplateText.rtrim()
return peekChar() = ' ';
   }
  @@ -369,6 +372,10 @@
skipSpaces();
stringBuffer.setLength(0);

  +if (!hasMoreInput()) { 
  +return ; 
  +} 
  +
int ch = peekChar();

if (quoted) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java

2004-10-06 Thread markt
markt   2004/10/06 15:46:41

  Modified:jasper2/src/share/org/apache/jasper/compiler Tag:
tomcat_4_branch JspReader.java
  Log:
  Fix bug 31550. Jasper now compilies JSP when tag attribute ends in .
   - Ported fix from TC5 branch.
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.5.2.6   +4 -1  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.5.2.5
  retrieving revision 1.5.2.6
  diff -u -r1.5.2.5 -r1.5.2.6
  --- JspReader.java25 Aug 2004 20:53:31 -  1.5.2.5
  +++ JspReader.java6 Oct 2004 22:46:41 -   1.5.2.6
  @@ -363,7 +363,10 @@
   skip:
   for (ret = mark(), ch = nextChar() ; ch != -1 ;
ret = mark(), prev = ch, ch = nextChar()) {
  -if (ch == limit.charAt(0)  prev != '\\') {
  +if (ch == '\\'  prev == '\\') {
  +ch = 0; // Double \ is not an escape char anymore
  +}
  +else if (ch == limit.charAt(0)  prev != '\\') {
   for (int i = 1 ; i  limlen ; i++) {
   if (peekChar() == limit.charAt(i))
   nextChar();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java

2004-07-27 Thread kinman
kinman  2004/07/27 14:57:03

  Modified:jasper2/src/share/org/apache/jasper/compiler JspReader.java
  Log:
  - Replace tabs with 8 spaces, in preparation for next commit.
  
  Revision  ChangesPath
  1.22  +250 -250  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- JspReader.java13 Jul 2004 18:40:08 -  1.21
  +++ JspReader.java27 Jul 2004 21:57:02 -  1.22
  @@ -70,34 +70,34 @@
* Constructor.
*/
   public JspReader(JspCompilationContext ctxt,
  -  String fname,
  -  String encoding,
  -  JarFile jarFile,
  -  ErrorDispatcher err)
  - throws JasperException, FileNotFoundException, IOException {
  -
  - this(ctxt, fname, encoding,
  -  JspUtil.getReader(fname, encoding, jarFile, ctxt, err),
  -  err);
  + String fname,
  + String encoding,
  + JarFile jarFile,
  + ErrorDispatcher err)
  +throws JasperException, FileNotFoundException, IOException {
  +
  +this(ctxt, fname, encoding,
  + JspUtil.getReader(fname, encoding, jarFile, ctxt, err),
  + err);
   }
   
   /*
* Constructor.
*/
   public JspReader(JspCompilationContext ctxt,
  -  String fname,
  -  String encoding,
  -  InputStreamReader reader,
  -  ErrorDispatcher err)
  - throws JasperException, FileNotFoundException {
  + String fname,
  + String encoding,
  + InputStreamReader reader,
  + ErrorDispatcher err)
  +throws JasperException, FileNotFoundException {
   
   this.context = ctxt;
  - this.err = err;
  - sourceFiles = new Vector();
  - currFileId = 0;
  - size = 0;
  - singleFile = false;
  - pushFile(fname, encoding, reader);
  +this.err = err;
  +sourceFiles = new Vector();
  +currFileId = 0;
  +size = 0;
  +singleFile = false;
  +pushFile(fname, encoding, reader);
   }
   
   /*
  @@ -109,35 +109,35 @@
   }
   
   String getFile(int fileid) {
  - return (String) sourceFiles.elementAt(fileid);
  +return (String) sourceFiles.elementAt(fileid);
   }
  - 
  +
   boolean hasMoreInput() throws JasperException {
  - if (current.cursor = current.stream.length) {
  +if (current.cursor = current.stream.length) {
   if (singleFile) return false; 
  - while (popFile()) {
  - if (current.cursor  current.stream.length) return true;
  - }
  - return false;
  - }
  - return true;
  +while (popFile()) {
  +if (current.cursor  current.stream.length) return true;
  +}
  +return false;
  +}
  +return true;
   }
   
   int nextChar() throws JasperException {
  - if (!hasMoreInput())
  - return -1;
  - 
  - int ch = current.stream[current.cursor];
  -
  - current.cursor++;
  - 
  - if (ch == '\n') {
  - current.line++;
  - current.col = 0;
  - } else {
  - current.col++;
  - }
  - return ch;
  +if (!hasMoreInput())
  +return -1;
  +
  +int ch = current.stream[current.cursor];
  +
  +current.cursor++;
  +
  +if (ch == '\n') {
  +current.line++;
  +current.col = 0;
  +} else {
  +current.col++;
  +}
  +return ch;
   }
   
   /**
  @@ -145,46 +145,46 @@
* and that the char to be pushed back is not '\n'.
*/
   void pushChar() {
  - current.cursor--;
  - current.col--;
  +current.cursor--;
  +current.col--;
   }
   
   String getText(Mark start, Mark stop) throws JasperException {
  - Mark oldstart = mark();
  - reset(start);
  - CharArrayWriter caw = new CharArrayWriter();
  - while (!stop.equals(mark()))
  - caw.write(nextChar());
  - caw.close();
  - reset(oldstart);
  - return caw.toString();
  +Mark oldstart = mark();
  +reset(start);
  +CharArrayWriter caw = new CharArrayWriter();
  +while (!stop.equals(mark()))
  +caw.write(nextChar());
  +caw.close();
  +reset(oldstart);
  +return caw.toString();
   }
   
   int peekChar() {
  - return 

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java

2003-07-01 Thread remm
remm2003/07/01 12:33:39

  Modified:jasper2/src/share/org/apache/jasper/compiler JspReader.java
  Log:
  - Improve error message (I got it once).
  
  Revision  ChangesPath
  1.17  +1 -1  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- JspReader.java8 Feb 2003 00:06:40 -   1.16
  +++ JspReader.java1 Jul 2003 19:33:39 -   1.17
  @@ -546,7 +546,7 @@
log.error(Exception parsing file , ex);
// Pop state being constructed:
popFile();
  - err.jspError(jsp.error.file.cannot.read, ze file);
  + err.jspError(jsp.error.file.cannot.read, file);
} finally {
if (reader != null) {
try {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java Parser.java

2003-02-03 Thread kinman
kinman  2003/02/03 15:11:59

  Modified:jasper2/src/share/org/apache/jasper/compiler JspReader.java
Parser.java
  Log:
  - Recognize ![CDATA[ text ]] in jsp:text, jsp:declaration, jsp:expression
and jsp:scriptlet.
  
  Revision  ChangesPath
  1.15  +1 -1  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JspReader.java22 Jan 2003 21:13:51 -  1.14
  +++ JspReader.java3 Feb 2003 23:11:58 -   1.15
  @@ -250,7 +250,7 @@
   /**
* search the stream for a match to a string
* @param string The string to match
  - * @return stronttrue/strong is one is found, the current position
  + * @return strongtrue/strong is one is found, the current position
* in stream is positioned after the search string, strong
*  false/strong otherwise, position in stream unchanged.
*/
  
  
  
  1.58  +101 -32   
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- Parser.java   17 Jan 2003 20:02:25 -  1.57
  +++ Parser.java   3 Feb 2003 23:11:59 -   1.58
  @@ -668,8 +668,12 @@
   
   /*
* XMLDeclarationBody ::=   ( S? '/' )
  - *| ( S? '' (Char* - (char* '')) ETag )
  + *| ( S? '' (Char* - (char* '')) CDSect?)* ETag
*| TRANSLATION_ERROR
  + * CDSect ::= CDStart CData CDEnd
  + * CDStart ::= '![CDATA['
  + * CData ::= (Char* - (Char* ']]' Char*))
  + * CDEnd ::= ']]'
*/
   private void parseXMLDeclaration(Node parent) throws JasperException {
   reader.skipSpaces();
  @@ -678,17 +682,35 @@
   err.jspError(start, jsp.error.unterminated,
   lt;jsp:declarationgt;);
   }
  -start = reader.mark();
  -Mark stop = reader.skipUntil();
  -if ((stop == null) || !reader.matchesETagWithoutLessThan(
  -jsp:declaration ) )
  -{
  + Mark stop;
  +String text;
  +while (true) {
  +start = reader.mark();
  +stop = reader.skipUntil();
  +if (stop == null) {
  +err.jspError(start, jsp.error.unterminated,
  +lt;jsp:declarationgt;);
  +}
  + text = parseScriptText(reader.getText(start, stop));
  +new Node.Declaration(text, start, parent);
  +if (reader.matches(![CDATA[)) {
  +start = reader.mark();
  +stop = reader.skipUntil(]]);
  +if (stop == null) {
  +err.jspError(start, jsp.error.unterminated, CDATA);
  +}
  + text = parseScriptText(reader.getText(start, stop));
  +new Node.Declaration(text, start, parent);
  +}
  +else {
  +break;
  +}
  + }
  + 
  +if (!reader.matchesETagWithoutLessThan( jsp:declaration ) ) {
   err.jspError(start, jsp.error.unterminated,
   lt;jsp:declarationgt;);
   }
  -
  -new Node.Declaration(parseScriptText(reader.getText(start, stop)),
  -  start, parent);
   }
   }
   
  @@ -708,7 +730,7 @@
   
   /*
* XMLExpressionBody ::=   ( S? '/' )
  - *   | ( S? '' (Char* - (char* '')) ETag )
  + *   | ( S? '' (Char* - (char* '')) CDSect?)* ETag )
*   | TRANSLATION_ERROR
*/
   private void parseXMLExpression(Node parent) throws JasperException {
  @@ -718,17 +740,34 @@
   err.jspError(start, jsp.error.unterminated,
   lt;jsp:expressiongt;);
   }
  -start = reader.mark();
  -Mark stop = reader.skipUntil();
  -if ((stop == null) || !reader.matchesETagWithoutLessThan(
  -jsp:expression ))
  -{
  +Mark stop;
  +String text;
  +while (true) {
  +start = reader.mark();
  +stop = reader.skipUntil();
  +

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java Mark.java

2002-12-13 Thread kinman
kinman  2002/12/13 13:13:26

  Modified:jasper2/src/share/org/apache/jasper/compiler JspReader.java
Mark.java
  Log:
  - Fix 15337: Provide better error handling than an ArrayIndexOutOfBoundException
  
  Revision  ChangesPath
  1.13  +25 -12
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- JspReader.java5 Dec 2002 17:56:43 -   1.12
  +++ JspReader.java13 Dec 2002 21:13:25 -  1.13
  @@ -132,7 +132,7 @@
singleFile = false;
   
loghelper = new Logger.Helper(JASPER_LOG, JspReader);
  - pushFile2(fname, encoding, reader);
  + pushFile(fname, encoding, reader);
   }
   
   String getFile(int fileid) {
  @@ -315,7 +315,7 @@
   
   int skipSpaces() throws JasperException {
int i = 0;
  - while (isSpace()) {
  + while (hasMoreInput()  isSpace()) {
i++;
nextChar();
}
  @@ -532,7 +532,11 @@
return sourceFiles.size() - 1;
   }
   
  -private void pushFile2(String file, String encoding, 
  +/**
  + * Push a file (and its associated Stream) on the file stack.  THe
  + * current position in the current file is remembered.
  + */
  +private void pushFile(String file, String encoding, 
   InputStreamReader reader) 
throws JasperException, FileNotFoundException {
   
  @@ -574,29 +578,38 @@
}
   }
   
  +/**
  + * Pop a file from the file stack.  The field current is retored
  + * to the value to point to the previous files, if any, and is set
  + * to null otherwise.
  + * @return true is there is a previous file on the stck.
  + * false otherwise.
  + */
   private boolean popFile() throws JasperException {
   
// Is stack created ? (will happen if the Jsp file we're looking at is
// missing.
  - if (current == null) 
  + if (current == null || currFileId  0) {
return false;
  + }
   
// Restore parser state:
  - //size--;
  - if (currFileId  0) {
  - err.jspError(jsp.error.no.more.content);
  - }
  - 
String fName = getFile(currFileId);
currFileId = unregisterSourceFile(fName);
if (currFileId  -1) {
err.jspError(jsp.error.file.not.registered, fName);
}
   
  - boolean result = current.popStream();
  - if (result)
  + Mark previous = current.popStream();
  + if (previous != null) {
master = current.baseDir;
  - return (result);
  + current = previous;
  + return true;
  + }
  + // Note that although the current file is undefined here, current
  + // is not set to null just for convience, for it maybe used to
  + // set the current (undefined) position.
  + return false;
   }
   }
   
  
  
  
  1.3   +12 -9 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java
  
  Index: Mark.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Mark.java 17 Oct 2002 20:43:06 -  1.2
  +++ Mark.java 13 Dec 2002 21:13:25 -  1.3
  @@ -189,13 +189,16 @@
stream = inStream;
   }
   
  -
  -
  -/** Restores this mark's state to a previously stored stream.
  +/**
  +/* Restores this mark's state to a previously stored stream.
  + * @return null if there is no previous stream
  + * The previous Makr instance when the stream is pushed.
*/
  -public boolean popStream() {
  +public Mark popStream() {
// make sure we have something to pop
  - if ( includeStack.size() = 0 ) return false;
  + if ( includeStack.size() = 0 ) {
  + return null;
  + }
   
// get previous state in stack
IncludeState state = (IncludeState) includeStack.pop( );
  @@ -208,7 +211,7 @@
fileName = state.fileName;
baseDir = state.baseDir;
stream = state.stream;
  - return true;
  + return this;
   }
   
   //  Locator interface 
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java

2002-10-09 Thread luehe

luehe   2002/10/09 17:49:21

  Modified:jasper2/src/share/org/apache/jasper JspC.java
JspCompilationContext.java
   jasper2/src/share/org/apache/jasper/compiler JspReader.java
  Log:
  Changed visibility of o.a.j.c.JspReader to package scope, and the visibility
  of some of its methods to private.
  
  Revision  ChangesPath
  1.15  +3 -4  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java
  
  Index: JspC.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JspC.java 21 Aug 2002 17:56:03 -  1.14
  +++ JspC.java 10 Oct 2002 00:49:21 -  1.15
  @@ -65,7 +65,6 @@
   import java.net.*;
   import java.util.*;
   
  -import org.apache.jasper.compiler.JspReader;
   import org.apache.jasper.compiler.ServletWriter;
   import org.apache.jasper.compiler.Compiler;
   import org.apache.jasper.compiler.TldLocationsCache;
  
  
  
  1.22  +3 -16 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java
  
  Index: JspCompilationContext.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- JspCompilationContext.java11 Sep 2002 19:07:32 -  1.21
  +++ JspCompilationContext.java10 Oct 2002 00:49:21 -  1.22
  @@ -68,7 +68,6 @@
   import javax.servlet.jsp.tagext.TagInfo;
   import javax.servlet.jsp.tagext.TagData;
   import org.apache.jasper.compiler.JspRuntimeContext;
  -import org.apache.jasper.compiler.JspReader;
   import org.apache.jasper.compiler.ServletWriter;
   import org.apache.jasper.compiler.Compiler;
   import org.apache.jasper.servlet.JspServletWrapper;
  @@ -100,7 +99,6 @@
   protected String jspPath;
   protected String classFileName;
   protected String contentType;
  -protected JspReader reader;
   protected ServletWriter writer;
   protected Options options;
   protected JspServletWrapper jsw;
  @@ -491,17 +489,6 @@
   
   public void setContentType(String contentType) {
   this.contentType = contentType;
  -}
  -
  -/**
  - * Get the input reader for the JSP text. 
  - */
  -public JspReader getReader() { 
  -return reader;
  -}
  -
  -public void setReader(JspReader reader) {
  -this.reader = reader;
   }
   
   /**
  
  
  
  1.10  +148 -137  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JspReader.java28 Aug 2002 23:50:10 -  1.9
  +++ JspReader.java10 Oct 2002 00:49:21 -  1.10
  @@ -80,137 +80,50 @@
* @author Mark Roth
*/
   
  -public class JspReader {
  +class JspReader {
   
  -protected Mark current  = null;
  -String master = null;
  -
  -Vector sourceFiles = new Vector();
  -int currFileId = 0;
  -int size = 0;
  -
  +private Mark current;
  +private String master;
  +private Vector sourceFiles;
  +private int currFileId;
  +private int size;
   private JspCompilationContext context;
   private ErrorDispatcher err;
  +private Logger.Helper loghelper;
   
   /*
* Set to true when using the JspReader on a single file where we read up
* to the end and reset to the beginning many times.
* (as in ParserCtl.figureOutJspDocument().
*/
  -boolean singleFile = false;
  +private boolean singleFile;
   
  -Logger.Helper loghelper = new Logger.Helper(JASPER_LOG, JspReader);
  -
  -public String getFile(int fileid) {
  - return (String) sourceFiles.elementAt(fileid);
  -}
  -
  -/**
  - * Register a new source file.
  - * This method is used to implement file inclusion. Each included file
  - * gets a uniq identifier (which is the index in the array of source files).
  - * @return The index of the now registered file.
  - */
  -protected int registerSourceFile(String file) {
  -if (sourceFiles.contains(file))
  -return -1;
  - sourceFiles.addElement(file);
  - this.size++;
  - return sourceFiles.size() - 1;
  -}
  -
  -
  -/**
  - * Unregister the source file.
  - * This method is used to implement file inclusion. Each included file
  - * gets a uniq identifier (which is the index in the array of source
  -  

cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java Parser.java

2002-07-18 Thread kinman

kinman  2002/07/18 13:18:10

  Modified:jasper2/src/share/org/apache/jasper/compiler JspReader.java
Parser.java
  Log:
  - Fixed 10713.  Modified on patch by [EMAIL PROTECTED] (Henner Zeller)
  
  Revision  ChangesPath
  1.7   +33 -2 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JspReader.java16 Jul 2002 19:30:51 -  1.6
  +++ JspReader.java18 Jul 2002 20:18:10 -  1.7
  @@ -393,14 +393,45 @@
* otherwise.
*/
   public Mark skipUntil(String limit) throws JasperException {
  +Mark ret = null;
  +int limlen = limit.length();
  +int ch;
  +
  +skip:
  +for (ret = mark(), ch = nextChar() ; ch != -1 ;
  + ret = mark(), ch = nextChar()) {
  +if (ch == limit.charAt(0)) {
  +for (int i = 1 ; i  limlen ; i++) {
  +if (peekChar() == limit.charAt(i))
  +nextChar();
  +else
  +continue skip;
  +}
  +return ret;
  +}
  +}
  +return null;
  +}
  +
  +/**
  + * Skip until the given string is matched in the stream, but ignoring
  + * chars initially escaped by a '\'.
  + * When returned, the context is positioned past the end of the match.
  + * @param s The String to match.
  + * @return A non-null codeMark/code instance (positioned immediately
  + * before the search string) if found, strongnull/strong
  + * otherwise.
  + */
  +public Mark skipUntilIgnoreEsc(String limit) throws JasperException {
Mark ret = null;
int limlen = limit.length();
int ch;
  + int prev = 'x'; // Doesn't matter

   skip:
for (ret = mark(), ch = nextChar() ; ch != -1 ;
  -  ret = mark(), ch = nextChar()) {   
  - if (ch == limit.charAt(0)) {
  +  ret = mark(), prev = ch, ch = nextChar()) {
  + if (ch == limit.charAt(0)  prev != '\\') {
for (int i = 1 ; i  limlen ; i++) {
if (peekChar() == limit.charAt(i))
nextChar();
  
  
  
  1.10  +4 -4  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Parser.java   17 Jul 2002 20:06:59 -  1.9
  +++ Parser.java   18 Jul 2002 20:18:10 -  1.10
  @@ -224,7 +224,7 @@
*/
   private String parseAttributeValue(String watch) throws JasperException {
Mark start = reader.mark();
  - Mark stop = reader.skipUntil(watch);
  + Mark stop = reader.skipUntilIgnoreEsc(watch);
if (stop == null) {
err.jspError(start, jsp.error.attribute.unterminated, watch);
}
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java Parser.java

2002-07-18 Thread kinman

kinman  2002/07/18 13:18:56

  Modified:jasper2/src/share/org/apache/jasper/compiler Tag:
tomcat_4_branch JspReader.java Parser.java
  Log:
  - Fixed 10713.  Modified on patch by [EMAIL PROTECTED] (Henner Zeller)
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.5.2.1   +31 -0 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- JspReader.java7 Jun 2002 20:04:27 -   1.5
  +++ JspReader.java18 Jul 2002 20:18:56 -  1.5.2.1
  @@ -385,6 +385,37 @@
   }
   
   /**
  + * Skip until the given string is matched in the stream, but ignoring
  + * chars initially escaped by a '\'.
  + * When returned, the context is positioned past the end of the match.
  + * @param s The String to match.
  + * @return A non-null codeMark/code instance (positioned immediately
  + * before the search string) if found, strongnull/strong
  + * otherwise.
  + */
  +public Mark skipUntilIgnoreEsc(String limit) throws JasperException {
  +Mark ret = null;
  +int limlen = limit.length();
  +int ch;
  +int prev = 'x'; // Doesn't matter
  +
  +skip:
  +for (ret = mark(), ch = nextChar() ; ch != -1 ;
  + ret = mark(), prev = ch, ch = nextChar()) {
  +if (ch == limit.charAt(0)  prev != '\\') {
  +for (int i = 1 ; i  limlen ; i++) {
  +if (peekChar() == limit.charAt(i))
  +nextChar();
  +else
  +continue skip;
  +}
  +return ret;
  +}
  +}
  +return null;
  +}
  +
  +/**
* Skip until the given end tag is matched in the stream.
* When returned, the context is positioned past the end of the tag.
* @param tag The name of the tag whose ETag (/tag) to match.
  
  
  
  1.7.2.1   +4 -4  
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- Parser.java   8 Jul 2002 23:47:55 -   1.7
  +++ Parser.java   18 Jul 2002 20:18:56 -  1.7.2.1
  @@ -212,7 +212,7 @@
*/
   private String parseAttributeValue(String watch) throws JasperException {
Mark start = reader.mark();
  - Mark stop = reader.skipUntil(watch);
  + Mark stop = reader.skipUntilIgnoreEsc(watch);
if (stop == null) {
err.jspError(start, jsp.error.attribute.unterminated, watch);
}
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler JspReader.java Parser.java

2002-04-16 Thread kinman

kinman  02/04/16 18:42:54

  Modified:jasper2/src/share/org/apache/jasper/compiler JspReader.java
Parser.java
  Log:
  - Implemented attribute parser in Parser.java.  Next step is to clean up
JspReader.java and remove now unused methods.
  
  Revision  ChangesPath
  1.4   +0 -37 
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java
  
  Index: JspReader.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspReader.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JspReader.java11 Apr 2002 18:14:03 -  1.3
  +++ JspReader.java17 Apr 2002 01:42:54 -  1.4
  @@ -280,43 +280,6 @@
return caw.toCharArray();
   }
   
  -/**
  - * Get the text for a scripting element from the stream.  It handles
  - * the escape string %\.
  - *
  - * @param start The starting postion to read
  - * @param stop The ending (exclusive) postion to read
  - * @return The resultant text
  - */
  -char[] getScriptingText(Mark start, Mark stop) throws JasperException {
  - Mark oldstart = mark();
  - reset(start);
  - CharArrayWriter caw = new CharArrayWriter();
  - while (!stop.equals(mark())) {
  - int c = nextChar();
  - caw.write(c);
  - if (c == '%') {
  - if (stop.equals(mark()))
  - break;
  - int c2 = nextChar();
  - if (stop.equals(mark())) {
  - caw.write(c2);
  - break;
  - }
  - int c3 = nextChar();
  - if (c2 == '\\'  c3 == '') {
  - caw.write('');
  - } else {
  - caw.write(c2);
  - caw.write(c3);
  - }
  - }
  - }
  - caw.close();
  - reset(oldstart);
  - return caw.toCharArray();
  -}
  -
   public int peekChar() {
return current.stream[current.cursor];
   }
  
  
  
  1.3   +178 -17   
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java
  
  Index: Parser.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Parser.java   4 Apr 2002 02:34:01 -   1.2
  +++ Parser.java   17 Apr 2002 01:42:54 -  1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
 1.2 2002/04/04 02:34:01 kinman Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/04/04 02:34:01 $
  + * $Header: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v
 1.3 2002/04/17 01:42:54 kinman Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/17 01:42:54 $
*
* 
* 
  @@ -61,10 +61,12 @@
   package org.apache.jasper.compiler;
   
   import java.io.FileNotFoundException;
  +import java.io.CharArrayWriter;
   import java.util.Hashtable;
   import javax.servlet.jsp.tagext.TagLibraryInfo;
   import javax.servlet.jsp.tagext.TagInfo;
   import org.xml.sax.Attributes;
  +import org.xml.sax.helpers.AttributesImpl;
   import org.apache.jasper.JspCompilationContext;
   import org.apache.jasper.JasperException;
   
  @@ -124,6 +126,160 @@
return page;
   }
   
  +/**
  + * Attributes ::= (S Attribute)* S?
  + */
  +Attributes parseAttributes() throws JasperException {
  + AttributesImpl attrs = new AttributesImpl();
  +
  + reader.skipSpaces();
  + while (parseAttribute(attrs))
  + reader.skipSpaces();
  +
  + return attrs;
  +}
  +
  +/**
  + * Attribute ::= Name S? Eq S?
  + *   (   '%= RTAttributeValueDouble
  + * | '' AttributeValueDouble
  + * | '%= RTAttributeValueSingle
  + * | ' AttributeValueSingle
  + *   }
  + * Note: JSP and XML spec does not allow while spaces around Eq.  It is
  + * added to be backward compatible with Tomcat, and with other xml parsers.
  + */
  +private boolean parseAttribute(AttributesImpl attrs) throws JasperException {
  + String name = parseName();
  + if (name == null)
  + return false;
  +
  + reader.skipSpaces();
  + if (!reader.matches(=))
  + err.jspError(reader.mark(), jsp.error.attribute.noequal);
  +
  + reader.skipSpaces();
  + char quote = (char) reader.nextChar();
  + if (quote != '\''  quote != '')
  + err.jspError(reader.mark(), jsp.error.attribute.noquote);
  +
  + String watchString = ;
  + if