remm 2003/08/09 12:18:22 Modified: jasper2/src/share/org/apache/jasper/compiler Parser.java Log: - Bug 22266: Keep template text together with mappedfile="true". Revision Changes Path 1.78 +58 -6 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java Index: Parser.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Parser.java,v retrieving revision 1.77 retrieving revision 1.78 diff -u -r1.77 -r1.78 --- Parser.java 23 Jul 2003 19:23:46 -0000 1.77 +++ Parser.java 9 Aug 2003 19:18:22 -0000 1.78 @@ -102,6 +102,7 @@ private boolean directivesOnly; private URL jarFileUrl; private PageInfo pageInfo; + private boolean mappedFile; // Virtual body content types, to make parsing a little easier. // These are not accessible from outside the parser. @@ -128,6 +129,7 @@ this.directivesOnly = directivesOnly; this.jarFileUrl = jarFileUrl; start = reader.mark(); + mappedFile = ctxt.getOptions().getMappedFile(); } /** @@ -1403,6 +1405,54 @@ return true; } + /** + * Determines whether the current text is template text + * or not. Assumes the reader is at the character + * following the "<". + */ + private boolean isTemplateText() throws JasperException { + + Mark m = reader.mark(); + int ch = reader.peekChar(); + if (ch == '/') { + reader.nextChar(); + } + String tagIdentifier = reader.parseToken(false); + reader.reset(m); + + if (tagIdentifier.equals("%--")) { + return false; + } + if (tagIdentifier.equals("%@")) { + return false; + } + if (tagIdentifier.equals("%!")) { + return false; + } + if (tagIdentifier.equals("%=")) { + return false; + } + if (tagIdentifier.equals("%")) { + return false; + } + if (tagIdentifier.startsWith("jsp:")) { + return false; + } + + // Check if this is a user-defined tag. + int i = tagIdentifier.indexOf(':'); + if (i == -1) { + return true; + } + String prefix = tagIdentifier.substring(0, i); + String uri = pageInfo.getURI(prefix); + if (uri == null) { + return true; + } + + return false; + } + /* * */ @@ -1419,9 +1469,11 @@ while (reader.hasMoreInput()) { ch = reader.nextChar(); if (ch == '<') { - reader.pushChar(); - break; - } + if (!mappedFile || !isTemplateText()) { + reader.pushChar(); + break; + } + } else if( ch == '$' ) { if (!reader.hasMoreInput()) { ttext.write('$');
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]