From: markt Date: Wed, 3 Mar 2010 21:00:22 +0000 (+0000) Subject: Revert previous fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=47977... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4a1612651cc4b53700092d2160a3bb6a7138b8b2;p=tomcat7.0 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 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@918684 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/jasper/compiler/JspDocumentParser.java b/java/org/apache/jasper/compiler/JspDocumentParser.java index e90023c43..351980b6e 100644 --- a/java/org/apache/jasper/compiler/JspDocumentParser.java +++ b/java/org/apache/jasper/compiler/JspDocumentParser.java @@ -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. *