From: markt Date: Sun, 5 Jul 2009 11:30:22 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=38797 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f806aaf1f712198b26d907672b9f37c06fe859aa;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=38797 Revert previous fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=37933 and implement an alternative that doesn't have the side effects described in 38797 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@791224 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java index fb589861b..95476ec37 100644 --- a/java/org/apache/jasper/compiler/Generator.java +++ b/java/org/apache/jasper/compiler/Generator.java @@ -31,6 +31,7 @@ import java.util.Hashtable; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.Vector; import javax.el.MethodExpression; @@ -86,6 +87,8 @@ class Generator { private ErrorDispatcher err; private BeanRepository beanInfo; + + private Set varInfoNames; private JspCompilationContext ctxt; @@ -1107,18 +1110,26 @@ class Generator { + ")_jspx_page_context.findAttribute(" + "\"" + name + "\"))." + methodName + "())));"); - } else { - // The object could be a custom action with an associated + } else if (varInfoNames.contains(name)) { + // The object is a custom action with an associated // VariableInfo entry for this name. // Get the class name and then introspect at runtime. out .printil("out.write(org.apache.jasper.runtime.JspRuntimeLibrary.toString" + "(org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty" - + "(_jspx_page_context.getAttribute(\"" + + "(_jspx_page_context.findAttribute(\"" + name - + "\", PageContext.PAGE_SCOPE), \"" + + "\"), \"" + property + "\")));"); + } else { + StringBuilder msg = + new StringBuilder("jsp:getProperty for bean with name '"); + msg.append(name); + msg.append( + "'. Name was not previously introduced as per JSP.5.3"); + + throw new JasperException(msg.toString()); } n.setEndJavaLine(out.getJavaLine()); @@ -1782,6 +1793,18 @@ class Generator { // restore previous writer out = outSave; } + + // Add the named objects to the lits of 'introduced' names to enable + // a later test as per JSP.5.3 + VariableInfo[] infos = n.getVariableInfos(); + if (infos != null && infos.length > 0) { + for (int i = 0; i < infos.length; i++) { + VariableInfo info = infos[i]; + if (info != null && info.getVarName() != null) + pageInfo.getVarInfoNames().add(info.getVarName()); + } + } + } private static final String DOUBLE_QUOTE = "\\\""; @@ -3364,6 +3387,7 @@ class Generator { isPoolingEnabled = false; } beanInfo = pageInfo.getBeanRepository(); + varInfoNames = pageInfo.getVarInfoNames(); breakAtLF = ctxt.getOptions().getMappedFile(); if (isPoolingEnabled) { tagHandlerPoolNames = new Vector(); diff --git a/java/org/apache/jasper/compiler/PageInfo.java b/java/org/apache/jasper/compiler/PageInfo.java index 84fba8a94..04a04df61 100644 --- a/java/org/apache/jasper/compiler/PageInfo.java +++ b/java/org/apache/jasper/compiler/PageInfo.java @@ -21,6 +21,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.Vector; import org.apache.el.ExpressionFactoryImpl; @@ -42,6 +43,7 @@ class PageInfo { private Vector dependants; private BeanRepository beanRepository; + private Set varInfoNames; private HashMap taglibsMap; private HashMap jspPrefixMapper; private HashMap> xmlPrefixMapper; @@ -98,6 +100,7 @@ class PageInfo { this.jspFile = jspFile; this.beanRepository = beanRepository; + this.varInfoNames = new HashSet(); this.taglibsMap = new HashMap(); this.jspPrefixMapper = new HashMap(); this.xmlPrefixMapper = new HashMap>(); @@ -707,4 +710,8 @@ class PageInfo { public void setTrimDirectiveWhitespaces(boolean trimDirectiveWhitespaces) { this.trimDirectiveWhitespaces = trimDirectiveWhitespaces; } + + public Set getVarInfoNames() { + return varInfoNames; + } }