Author: markt
Date: Tue Jan 12 00:10:46 2010
New Revision: 898126
URL: http://svn.apache.org/viewvc?rev=898126&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47977
Using a body with tags specified to have empty body content should cause an
error
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=898126&r1=898125&r2=898126&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
(original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java Tue Jan
12 00:10:46 2010
@@ -109,6 +109,8 @@
// 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
@@ -269,6 +271,8 @@
AttributesImpl nonTaglibAttrs = null;
AttributesImpl nonTaglibXmlnsAttrs = null;
+ checkEmptyBody();
+
processChars();
checkPrefixes(uri, qName, attrs);
@@ -426,9 +430,10 @@
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.equals(bodyType)) {
+ tagEmptyBody = node;
}
}
}
@@ -453,7 +458,10 @@
* @throws SAXException
*/
@Override
- public void characters(char[] buf, int offset, int len) {
+ public void characters(char[] buf, int offset, int len)
+ throws SAXException {
+
+ checkEmptyBody();
if (charBuffer == null) {
charBuffer = new StringBuilder();
@@ -613,6 +621,10 @@
public void endElement(String uri, String localName, String qName)
throws SAXException {
+ if (tagEmptyBody != null) {
+ tagEmptyBody = null;
+ }
+
processChars();
if (directivesOnly &&
@@ -703,6 +715,7 @@
*/
public void startCDATA() throws SAXException {
+ checkEmptyBody();
processChars(); // Flush char buffer and remove white spaces
startMark = new Mark(ctxt, path, locator.getLineNumber(),
locator.getColumnNumber());
@@ -1388,6 +1401,13 @@
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: [email protected]
For additional commands, e-mail: [email protected]