You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ki...@apache.org on 2005/01/11 23:14:55 UTC
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler ParserController.java
kinman 2005/01/11 14:14:55
Modified: jasper2/src/share/org/apache/jasper/compiler
ParserController.java
Log:
- Fix 29771: page encoding in a page directive inside a comment should be ignored.
Revision Changes Path
1.56 +19 -52 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java
Index: ParserController.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/ParserController.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- ParserController.java 23 Sep 2004 06:59:09 -0000 1.55
+++ ParserController.java 11 Jan 2005 22:14:55 -0000 1.56
@@ -401,40 +401,31 @@
jspReader.reset(startMark);
/*
- * Determine page encoding from directive of the form <%@ page %> or
- * <%@ tag %>
+ * Determine page encoding from directive of the form <%@ page %>,
+ * <%@ tag %>, <jsp:directive.page > or <jsp:directive.tag >.
*/
while (true) {
- Mark current = jspReader.mark();
-
- Mark beginDirective = jspReader.skipUntil("<%@");
- if (beginDirective == null) {
+ if (jspReader.skipUntil("<") == null) {
break;
}
- // Move past the '<%@' delimiter
- Mark beginDirectiveBody = jspReader.mark();
-
- // Check to see if directive is nested inside comment
- jspReader.reset(current);
- Mark beginComment = jspReader.skipUntil("<%--");
- if (beginComment != null) {
- Mark endComment = jspReader.skipUntil("--%>");
- if (endComment == null) {
- err.jspError(beginComment, "jsp.error.unterminated",
- "<%--");
- }
-
- if (beginDirective.isGreater(beginComment)
- && endComment.isGreater(beginDirective)) {
- // Directive is nested inside comment, skip until end of
- // comment
- jspReader.reset(endComment);
- continue;
+ // If this is a comment, skip until its end
+ if (jspReader.matches("%--")) {
+ if (jspReader.skipUntil("--%>") == null) {
+ // error will be caught in Parser
+ break;
}
+ continue;
+ }
+ boolean isDirective = jspReader.matches("%@");
+ if (isDirective) {
+ jspReader.skipSpaces();
+ }
+ else {
+ isDirective = jspReader.matches("jsp:directive.");
+ }
+ if (!isDirective) {
+ continue;
}
-
- jspReader.reset(beginDirectiveBody);
- jspReader.skipSpaces();
// compare for "tag ", so we don't match "taglib"
if (jspReader.matches("tag ") || jspReader.matches("page")) {
@@ -455,30 +446,6 @@
if (encoding == null) {
encoding = saveEncoding;
}
-
- if (encoding == null) {
- /*
- * Determine page encoding from page directive of the form
- * <jsp:directive.page>
- */
- jspReader.reset(startMark);
- while (jspReader.skipUntil("<jsp:directive.page") != null) {
- jspReader.skipSpaces();
- Attributes attrs = Parser.parseAttributes(this, jspReader);
-
- encoding = getPageEncodingFromDirective(attrs, "pageEncoding");
- if (encoding != null) {
- break;
- }
- encoding = getPageEncodingFromDirective(attrs, "contentType");
- if (encoding != null) {
- saveEncoding = encoding;
- }
- }
- if (encoding == null) {
- encoding = saveEncoding;
- }
- }
return encoding;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org