cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler ParserController.java Mark.java
luehe 2004/08/10 16:16:09 Modified:jasper2/src/share/org/apache/jasper/compiler Tag: TOMCAT_5_0 ParserController.java Mark.java Log: Ported fix for Bugzilla 29971 (Commented out page directive is parsed) Revision ChangesPath No revision No revision 1.52.2.1 +34 -2 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.52 retrieving revision 1.52.2.1 diff -u -r1.52 -r1.52.2.1 --- ParserController.java 17 Mar 2004 19:23:03 - 1.52 +++ ParserController.java 10 Aug 2004 23:16:08 - 1.52.2.1 @@ -407,13 +407,44 @@ String encoding = null; String saveEncoding = null; +jspReader.reset(startMark); + /* * Determine page encoding from directive of the form %@ page % or * %@ tag % */ - jspReader.reset(startMark); - while (jspReader.skipUntil(%@) != null) { +while (true) { +Mark current = jspReader.mark(); + +Mark beginDirective = jspReader.skipUntil(%@); +if (beginDirective == 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, + lt;%--); +} + +if (beginDirective.isGreater(beginComment) + endComment.isGreater(beginDirective)) { +// Directive is nested inside comment, skip until end of +// comment +jspReader.reset(endComment); +continue; +} +} + +jspReader.reset(beginDirectiveBody); jspReader.skipSpaces(); + // compare for tag , so we don't match taglib if (jspReader.matches(tag ) || jspReader.matches(page)) { @@ -429,6 +460,7 @@ } } } + if (encoding == null) { encoding = saveEncoding; } 1.7.2.1 +16 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java Index: Mark.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -r1.7 -r1.7.2.1 --- Mark.java 12 May 2004 17:45:37 - 1.7 +++ Mark.java 10 Aug 2004 23:16:08 - 1.7.2.1 @@ -227,6 +227,22 @@ return false; } +/** + * @return true if this Mark is greather than the codeother/code + * Mark, false otherwise. + */ +public boolean isGreater(Mark other) { + +boolean greater = false; + +if (this.line other.line) { +greater = true; +} else if (this.line == other.line this.col other.col) { +greater = true; +} + +return greater; +} /** * Keep track of parser before parsing an included file. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler ParserController.java Mark.java
luehe 2004/07/12 15:54:33 Modified:jasper2/src/share/org/apache/jasper/compiler ParserController.java Mark.java Log: Fixed Bugzilla 29971 (Commented out page directive is parsed) Revision ChangesPath 1.53 +34 -2 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.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- ParserController.java 17 Mar 2004 19:23:03 - 1.52 +++ ParserController.java 12 Jul 2004 22:54:33 - 1.53 @@ -407,13 +407,44 @@ String encoding = null; String saveEncoding = null; +jspReader.reset(startMark); + /* * Determine page encoding from directive of the form %@ page % or * %@ tag % */ - jspReader.reset(startMark); - while (jspReader.skipUntil(%@) != null) { +while (true) { +Mark current = jspReader.mark(); + +Mark beginDirective = jspReader.skipUntil(%@); +if (beginDirective == 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, + lt;%--); +} + +if (beginDirective.isGreater(beginComment) + endComment.isGreater(beginDirective)) { +// Directive is nested inside comment, skip until end of +// comment +jspReader.reset(endComment); +continue; +} +} + +jspReader.reset(beginDirectiveBody); jspReader.skipSpaces(); + // compare for tag , so we don't match taglib if (jspReader.matches(tag ) || jspReader.matches(page)) { @@ -429,6 +460,7 @@ } } } + if (encoding == null) { encoding = saveEncoding; } 1.8 +16 -0 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java Index: Mark.java === RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Mark.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Mark.java 12 May 2004 17:45:37 - 1.7 +++ Mark.java 12 Jul 2004 22:54:33 - 1.8 @@ -227,6 +227,22 @@ return false; } +/** + * @return true if this Mark is greather than the codeother/code + * Mark, false otherwise. + */ +public boolean isGreater(Mark other) { + +boolean greater = false; + +if (this.line other.line) { +greater = true; +} else if (this.line == other.line this.col other.col) { +greater = true; +} + +return greater; +} /** * Keep track of parser before parsing an included file. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]