tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kin-Man Chung <Kin-Man.Ch...@Eng.Sun.COM>
Subject [PATH] XML fragments in jsp handled incorrectly
Date Wed, 12 Sep 2001 19:00:49 GMT
This patch fixes #3350.  In a JSP document, the tags in a XML fragment are
always generated before the characters.  The current fix preserves their
orders.

misto% runsocks cvs diff -u ParserXJspSaxHandler.java
Index: ParserXJspSaxHandler.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-tomcat-4.0/jasper/src/share/org/apache/jasper/compiler/P
arserXJspSaxHandler.java,v
retrieving revision 1.13
diff -u -r1.13 ParserXJspSaxHandler.java
--- ParserXJspSaxHandler.java   2001/04/27 18:09:31     1.13
+++ ParserXJspSaxHandler.java   2001/09/12 18:33:59
@@ -233,8 +233,9 @@
 
         // If previous node is a custom tag, call its
         // begin tag handler
-        if (!name.equals("jsp:root")) {
-            Node prevNode = (Node)stack.peek();
+        Node prevNode = null;
+       if (!stack.empty()) {
+           prevNode = (Node)stack.peek();
             if (prevNode instanceof NodeTag) {
                 try {
                     processCustomTagBeginDoIt((NodeTag) prevNode, true);
@@ -273,6 +274,16 @@
                }
                if (!isCustomTag) {
                    // uninterpreted tag
+                   // If the parent tag is also uninterpreted, then the
+                   // characters have to be flushed, to preserve the order
+                   // of the tags and charaters that may appear in a XML
+                   // fragment, such as <a>xyz<b></b></a>
+                   if (prevNode != null && prevNode.isUninterpretedTag() &&
+                                               prevNode.getText() != null) {
+                       jspHandler.handleCharData(prevNode.start, start,
+                                                       prevNode.getText());
+                       prevNode.clearText();
+                   }
                    node.setUninterpreted(true);
                    jspHandler.handleUninterpretedTagBegin(node.start, 
                             node.start, node.rawName, node.attrs);
@@ -646,6 +657,10 @@
            ? null
            : text.toString().toCharArray();
         }
+
+       void clearText() {
+           text = null;
+       }
 
        boolean isRoot() {
            return isRoot;


Mime
View raw message