Revert previous fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=47977...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 3 Mar 2010 21:00:22 +0000 (21:00 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 3 Mar 2010 21:00:22 +0000 (21:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@918684 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/JspDocumentParser.java

index e90023c..351980b 100644 (file)
@@ -109,8 +109,6 @@ class JspDocumentParser
     // Flag set to delay incrementing tagDependentNesting until jsp:body
     // is first encountered
     private boolean tagDependentPending = false;
-    // Tag being parsed that should have an empty body 
-    private Node tagEmptyBody = null;
 
     /*
      * Constructor
@@ -271,8 +269,6 @@ class JspDocumentParser
         AttributesImpl nonTaglibAttrs = null;
         AttributesImpl nonTaglibXmlnsAttrs = null;
 
-        checkEmptyBody();
-
         processChars();
 
         checkPrefixes(uri, qName, attrs);
@@ -430,10 +426,9 @@ class JspDocumentParser
                 if (scriptlessBodyNode == null
                         && bodyType.equalsIgnoreCase(TagInfo.BODY_CONTENT_SCRIPTLESS)) {
                     scriptlessBodyNode = node;
-                } else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType)) {
+                }
+                else if (TagInfo.BODY_CONTENT_TAG_DEPENDENT.equalsIgnoreCase(bodyType)) {
                     tagDependentPending = true;
-                } else if (TagInfo.BODY_CONTENT_EMPTY.equalsIgnoreCase(bodyType)) {
-                    tagEmptyBody = node;
                 }
             }
         }
@@ -458,10 +453,7 @@ class JspDocumentParser
      * @throws SAXException
      */
     @Override
-    public void characters(char[] buf, int offset, int len)
-    throws SAXException {
-
-        checkEmptyBody();
+    public void characters(char[] buf, int offset, int len) {
 
         if (charBuffer == null) {
             charBuffer = new StringBuilder();
@@ -621,10 +613,6 @@ class JspDocumentParser
     public void endElement(String uri, String localName, String qName)
         throws SAXException {
 
-        if (tagEmptyBody != null) {
-            tagEmptyBody = null;
-        }
-        
         processChars();
 
         if (directivesOnly &&
@@ -676,6 +664,23 @@ class JspDocumentParser
             scriptlessBodyNode = null;
         }
 
+        if (current instanceof Node.CustomTag) {
+               String bodyType = getBodyType((Node.CustomTag) current);
+               if (TagInfo.BODY_CONTENT_EMPTY.equalsIgnoreCase(bodyType)) {
+                       // Children - if any - must be JSP attributes
+                       Node.Nodes children = current.getBody();
+                       if (children != null && children.size() > 0) {
+                               for (int i = 0; i < children.size(); i++) {
+                                       Node child = children.getNode(i);
+                                       if (!(child instanceof Node.NamedAttribute)) {
+                                               throw new SAXParseException(Localizer.getMessage(
+                                                               "jasper.error.emptybodycontent.nonempty",
+                                                               current.qName), locator); 
+                                       }
+                               }
+                       }
+               }
+        }
         if (current.getParent() != null) {
             current = current.getParent();
         }
@@ -715,7 +720,6 @@ class JspDocumentParser
      */
     public void startCDATA() throws SAXException {
 
-        checkEmptyBody();
         processChars();  // Flush char buffer and remove white spaces
         startMark = new Mark(ctxt, path, locator.getLineNumber(),
                              locator.getColumnNumber());
@@ -1401,13 +1405,6 @@ class JspDocumentParser
         return "";
     }
 
-    private void checkEmptyBody() throws SAXException {
-        if (tagEmptyBody != null) {
-            throw new SAXParseException(Localizer.getMessage(
-                    "jasper.error.emptybodycontent.nonempty",
-                    tagEmptyBody.qName), locator);
-        }
-    }
     /*
      * Gets SAXParser.
      *