Author: markt
Date: Wed Mar  3 21:00:22 2010
New Revision: 918684

URL: http://svn.apache.org/viewvc?rev=918684&view=rev
Log:
Revert previous fix for 
https://issues.apache.org/bugzilla/show_bug.cgi?id=47977 that caused regression 
https://issues.apache.org/bugzilla/show_bug.cgi?id=48827 and implement an 
alternative fix

Modified:
    tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java

Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java?rev=918684&r1=918683&r2=918684&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java 
(original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java Wed Mar 
 3 21:00:22 2010
@@ -109,8 +109,6 @@
     // 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 @@
         AttributesImpl nonTaglibAttrs = null;
         AttributesImpl nonTaglibXmlnsAttrs = null;
 
-        checkEmptyBody();
-
         processChars();
 
         checkPrefixes(uri, qName, attrs);
@@ -430,10 +426,9 @@
                 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 @@
      * @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 @@
     public void endElement(String uri, String localName, String qName)
         throws SAXException {
 
-        if (tagEmptyBody != null) {
-            tagEmptyBody = null;
-        }
-        
         processChars();
 
         if (directivesOnly &&
@@ -676,6 +664,23 @@
             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 @@
      */
     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 @@
         return "";
     }
 
-    private void checkEmptyBody() throws SAXException {
-        if (tagEmptyBody != null) {
-            throw new SAXParseException(Localizer.getMessage(
-                    "jasper.error.emptybodycontent.nonempty",
-                    tagEmptyBody.qName), locator);
-        }
-    }
     /*
      * Gets SAXParser.
      *



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to