Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 63336 invoked from network); 31 Oct 2006 16:29:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Oct 2006 16:29:27 -0000 Received: (qmail 70307 invoked by uid 500); 31 Oct 2006 16:29:33 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 70256 invoked by uid 500); 31 Oct 2006 16:29:33 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 70243 invoked by uid 500); 31 Oct 2006 16:29:33 -0000 Delivered-To: apmail-jakarta-tomcat-dev@jakarta.apache.org Received: (qmail 70240 invoked by uid 99); 31 Oct 2006 16:29:32 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Oct 2006 08:29:32 -0800 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Oct 2006 08:29:19 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 8CDF51A984D; Tue, 31 Oct 2006 08:28:56 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r469542 - in /tomcat/tc6.0.x/trunk/java/org/apache/jasper: compiler/ImplicitTagLibraryInfo.java resources/LocalStrings.properties Date: Tue, 31 Oct 2006 16:28:56 -0000 To: tomcat-dev@jakarta.apache.org From: remm@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061031162856.8CDF51A984D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: remm Date: Tue Oct 31 08:28:55 2006 New Revision: 469542 URL: http://svn.apache.org/viewvc?view=rev&rev=469542 Log: - Add parsing of implicit.tld for tag files. Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java?view=diff&rev=469542&r1=469541&r2=469542 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java Tue Oct 31 08:28:55 2006 @@ -17,13 +17,22 @@ package org.apache.jasper.compiler; -import java.util.*; +import java.io.InputStream; +import java.util.Collection; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Set; +import java.util.Vector; + import javax.servlet.jsp.tagext.FunctionInfo; -import javax.servlet.jsp.tagext.TagLibraryInfo; -import javax.servlet.jsp.tagext.TagInfo; import javax.servlet.jsp.tagext.TagFileInfo; -import org.apache.jasper.JspCompilationContext; +import javax.servlet.jsp.tagext.TagInfo; +import javax.servlet.jsp.tagext.TagLibraryInfo; + import org.apache.jasper.JasperException; +import org.apache.jasper.JspCompilationContext; +import org.apache.jasper.xmlparser.ParserUtils; +import org.apache.jasper.xmlparser.TreeNode; /** * Class responsible for generating an implicit tag library containing tag @@ -40,6 +49,7 @@ private static final String TAGS_SHORTNAME = "tags"; private static final String TLIB_VERSION = "1.0"; private static final String JSP_VERSION = "2.0"; + private static final String IMPLICIT_TLD = "implicit.tld"; // Maps tag names to tag file paths private Hashtable tagFileMap; @@ -52,59 +62,115 @@ * Constructor. */ public ImplicitTagLibraryInfo(JspCompilationContext ctxt, - ParserController pc, - PageInfo pi, - String prefix, - String tagdir, - ErrorDispatcher err) throws JasperException { + ParserController pc, + PageInfo pi, + String prefix, + String tagdir, + ErrorDispatcher err) throws JasperException { super(prefix, null); - this.pc = pc; - this.pi = pi; - this.tagFileMap = new Hashtable(); - this.vec = new Vector(); + this.pc = pc; + this.pi = pi; + this.tagFileMap = new Hashtable(); + this.vec = new Vector(); // Implicit tag libraries have no functions: this.functions = new FunctionInfo[0]; - tlibversion = TLIB_VERSION; - jspversion = JSP_VERSION; + tlibversion = TLIB_VERSION; + jspversion = JSP_VERSION; - if (!tagdir.startsWith(WEB_INF_TAGS)) { - err.jspError("jsp.error.invalid.tagdir", tagdir); - } - - // Determine the value of the subelement of the - // "imaginary" element - if (tagdir.equals(WEB_INF_TAGS) - || tagdir.equals( WEB_INF_TAGS + "/")) { - shortname = TAGS_SHORTNAME; - } else { - shortname = tagdir.substring(WEB_INF_TAGS.length()); - shortname = shortname.replace('/', '-'); - } - - // Populate mapping of tag names to tag file paths - Set dirList = ctxt.getResourcePaths(tagdir); - if (dirList != null) { - Iterator it = dirList.iterator(); - while (it.hasNext()) { - String path = (String) it.next(); - if (path.endsWith(TAG_FILE_SUFFIX) - || path.endsWith(TAGX_FILE_SUFFIX)) { - /* - * Use the filename of the tag file, without the .tag or - * .tagx extension, respectively, as the subelement - * of the "imaginary" element - */ - String suffix = path.endsWith(TAG_FILE_SUFFIX) ? - TAG_FILE_SUFFIX : TAGX_FILE_SUFFIX; - String tagName = path.substring(path.lastIndexOf("/") + 1); - tagName = tagName.substring(0, - tagName.lastIndexOf(suffix)); - tagFileMap.put(tagName, path); - } - } - } + if (!tagdir.startsWith(WEB_INF_TAGS)) { + err.jspError("jsp.error.invalid.tagdir", tagdir); + } + + // Determine the value of the subelement of the + // "imaginary" element + if (tagdir.equals(WEB_INF_TAGS) + || tagdir.equals( WEB_INF_TAGS + "/")) { + shortname = TAGS_SHORTNAME; + } else { + shortname = tagdir.substring(WEB_INF_TAGS.length()); + shortname = shortname.replace('/', '-'); + } + + // Populate mapping of tag names to tag file paths + Set dirList = ctxt.getResourcePaths(tagdir); + if (dirList != null) { + Iterator it = dirList.iterator(); + while (it.hasNext()) { + String path = (String) it.next(); + if (path.endsWith(TAG_FILE_SUFFIX) + || path.endsWith(TAGX_FILE_SUFFIX)) { + /* + * Use the filename of the tag file, without the .tag or + * .tagx extension, respectively, as the subelement + * of the "imaginary" element + */ + String suffix = path.endsWith(TAG_FILE_SUFFIX) ? + TAG_FILE_SUFFIX : TAGX_FILE_SUFFIX; + String tagName = path.substring(path.lastIndexOf("/") + 1); + tagName = tagName.substring(0, + tagName.lastIndexOf(suffix)); + tagFileMap.put(tagName, path); + } else if (path.endsWith(IMPLICIT_TLD)) { + InputStream in = null; + try { + in = ctxt.getResourceAsStream(path); + if (in != null) { + + // Add implicit TLD to dependency list + if (pi != null) { + pi.addDependant(path); + } + + ParserUtils pu = new ParserUtils(); + TreeNode tld = pu.parseXMLDocument(uri, in); + + if (tld.findAttribute("version") != null) { + this.jspversion = tld.findAttribute("version"); + } + + // Process each child element of our element + Iterator list = tld.findChildren(); + + while (list.hasNext()) { + TreeNode element = (TreeNode) list.next(); + String tname = element.getName(); + + if ("tlibversion".equals(tname) // JSP 1.1 + || "tlib-version".equals(tname)) { // JSP 1.2 + this.tlibversion = element.getBody(); + } else if ("jspversion".equals(tname) + || "jsp-version".equals(tname)) { + this.jspversion = element.getBody(); + } else if ("shortname".equals(tname) || "short-name".equals(tname)) { + // Ignore + } else { + // All other elements are invalid + err.jspError("jsp.error.invalid.implicit", path); + } + } + try { + double version = Double.parseDouble(this.jspversion); + if (version < 2.0) { + err.jspError("jsp.error.invalid.implicit.version", path); + } + } catch (NumberFormatException e) { + err.jspError("jsp.error.invalid.implicit.version", path); + } + } + } finally { + if (in != null) { + try { + in.close(); + } catch (Throwable t) { + } + } + } + } + } + } + } /** @@ -116,36 +182,36 @@ */ public TagFileInfo getTagFile(String shortName) { - TagFileInfo tagFile = super.getTagFile(shortName); - if (tagFile == null) { - String path = (String) tagFileMap.get(shortName); - if (path == null) { - return null; - } - - TagInfo tagInfo = null; - try { - tagInfo = TagFileProcessor.parseTagFileDirectives(pc, - shortName, - path, - this); - } catch (JasperException je) { - throw new RuntimeException(je.toString(), je); - } - - tagFile = new TagFileInfo(shortName, path, tagInfo); - vec.addElement(tagFile); - - this.tagFiles = new TagFileInfo[vec.size()]; - vec.copyInto(this.tagFiles); - } + TagFileInfo tagFile = super.getTagFile(shortName); + if (tagFile == null) { + String path = (String) tagFileMap.get(shortName); + if (path == null) { + return null; + } + + TagInfo tagInfo = null; + try { + tagInfo = TagFileProcessor.parseTagFileDirectives(pc, + shortName, + path, + this); + } catch (JasperException je) { + throw new RuntimeException(je.toString(), je); + } + + tagFile = new TagFileInfo(shortName, path, tagInfo); + vec.addElement(tagFile); + + this.tagFiles = new TagFileInfo[vec.size()]; + vec.copyInto(this.tagFiles); + } - return tagFile; + return tagFile; } - + public TagLibraryInfo[] getTagLibraryInfos() { Collection coll = pi.getTaglibs(); return (TagLibraryInfo[]) coll.toArray(new TagLibraryInfo[0]); } - + } Modified: tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties?view=diff&rev=469542&r1=469541&r2=469542 ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/jasper/resources/LocalStrings.properties Tue Oct 31 08:28:55 2006 @@ -77,6 +77,8 @@ jsp.error.unknownException=Unhandled error! You might want to consider having an error page \ to report such errors more gracefully jsp.error.invalid.directive=Invalid directive +jsp.error.invalid.implicit=Invalid implicit TLD for tag file at {0} +jsp.error.invalid.implicit.version=Invalid JSP version defined in implicit TLD for tag file at {0} jsp.error.directive.istagfile={0} directive cannot be used in a tag file jsp.error.directive.isnottagfile={0} directive can only be used in a tag file jsp.error.tagfile.tld.name=The \"name\" attribute of the tag directive has a value {0} while the \"name\" tag of the \"tag-file\" element in the TLD is {1} --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org