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  Changes    Path
  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.java    22 Jan 2003 21:13:51 -0000      1.14
  +++ JspReader.java    3 Feb 2003 23:11:58 -0000       1.15
  @@ -250,7 +250,7 @@
       /**
        * search the stream for a match to a string
        * @param string The string to match
  -     * @return <stront>true</strong> is one is found, the current position
  +     * @return <strong>true</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 -0000      1.57
  +++ Parser.java       3 Feb 2003 23:11:59 -0000       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:declaration&gt;");
               }
  -            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:declaration&gt;");
  +                }
  +             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:declaration&gt;");
               }
  -
  -            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:expression&gt;");
               }
  -            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("<");
  +                if (stop == null) {
  +                    err.jspError(start, "jsp.error.unterminated",
  +                        "&lt;jsp:expression&gt;");
  +                }
  +                text = parseScriptText(reader.getText(start, stop));
  +                new Node.Expression(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.Expression(text, start, parent);
  +                }
  +                else {
  +                    break;
  +                }
  +            }
  +            if (!reader.matchesETagWithoutLessThan( "jsp:expression" )) {
                   err.jspError(start, "jsp.error.unterminated",
                       "&lt;jsp:expression&gt;");
               }
  -
  -            new Node.Expression(parseScriptText(reader.getText(start, stop)),
  -                             start, parent);
           }
       }
   
  @@ -779,7 +818,7 @@
   
       /*
        * XMLScriptletBody ::=   ( S? '/>' )
  -     *                      | ( S? '>' (Char* - (char* '<')) ETag )
  +     *                      | ( S? '>' (Char* - (char* '<')) CDSect?)* ETag )
        *                      | <TRANSLATION_ERROR>
        */
       private void parseXMLScriptlet(Node parent) throws JasperException {
  @@ -789,17 +828,35 @@
                   err.jspError(start, "jsp.error.unterminated",
                       "&lt;jsp:scriptlet&gt;");
               }
  -            start = reader.mark();
  -            Mark stop = reader.skipUntil("<");
  -            if ((stop == null) || !reader.matchesETagWithoutLessThan(
  -                "jsp:scriptlet" ))
  -            {
  +            Mark stop;
  +            String text;
  +            while (true) {
  +                start = reader.mark();
  +                stop = reader.skipUntil("<");
  +                if (stop == null) {
  +                    err.jspError(start, "jsp.error.unterminated",
  +                        "&lt;jsp:scriptlet&gt;");
  +                }
  +                text = parseScriptText(reader.getText(start, stop));
  +                new Node.Scriptlet(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.Scriptlet(text, start, parent);
  +                }
  +                else {
  +                    break;
  +                }
  +            }
  +
  +            if (!reader.matchesETagWithoutLessThan( "jsp:scriptlet" )) {
                   err.jspError(start, "jsp.error.unterminated",
                       "&lt;jsp:scriptlet&gt;");
               }
  -
  -            new Node.Scriptlet(parseScriptText(reader.getText(start, stop)),
  -                            start, parent );
           }
       }
        
  @@ -1338,6 +1395,7 @@
        *                     | ( S? '>'
        *                         ( ( Char* - ( Char* ( '<' | '${' ) ) )
        *                           ( '${' ELExpressionBody )?
  +     *                           CDSect?
        *                         )* ETag
        *                       )
        *                     | <TRANSLATION_ERROR>
  @@ -1358,8 +1416,19 @@
                           "&lt;jsp:text&gt;" );
                       break;
                   }
  -                if( ch == '<' ) break;
  -                if( (lastCh == '$') && (ch == '{') ) {
  +                if( ch == '<' ) {
  +                    // Check for <![CDATA[
  +                    if (!reader.matches("![CDATA["))
  +                        break;
  +                    start = reader.mark();
  +                    Mark stop = reader.skipUntil("]]>");
  +                    if (stop == null) {
  +                        err.jspError(start, "jsp.error.unterminated", "CDATA");
  +                    }
  +                    String text = reader.getText(start, stop);
  +                    ttext.write(text, 0, text.length());
  +                }
  +                else if( (lastCh == '$') && (ch == '{') ) {
                       // Create a template text node
                       new Node.TemplateText( ttext.toString(), start, parent);
   
  
  
  

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

Reply via email to