luehe       2002/12/13 07:34:40

  Modified:    jasper2/src/share/org/apache/jasper/compiler Validator.java
  Log:
  Fixed 15354: Jasper doesn't cause a translation error if an EL or RT
  expression is provided to an attribute of jsp:plugin that doesn't
  accept dynamic attribute values.
  
  Revision  Changes    Path
  1.58      +46 -23    
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java
  
  Index: Validator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Validator.java,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- Validator.java    9 Dec 2002 23:27:03 -0000       1.57
  +++ Validator.java    13 Dec 2002 15:34:39 -0000      1.58
  @@ -478,11 +478,7 @@
                                       paramActionAttrs, err);
            // make sure the value of the 'name' attribute is not a
            // request-time expression
  -         if (isExpression(n, n.getAttributes().getValue("name"))) {
  -             err.jspError(n,
  -                          "jsp.error.attribute.standard.non_rt_with_expr",
  -                          "name", "jsp:param");
  -         }
  +         throwErrorIfExpression(n, "name", "jsp:param");
            n.setValue(getJspAttribute("value", null, null,
                                       n.getAttributeValue("value"),
                                          java.lang.String.class, null,
  @@ -575,6 +571,18 @@
        public void visit(Node.PlugIn n) throws JasperException {
               JspUtil.checkAttributes("Plugin", n, plugInAttrs, err);
   
  +         throwErrorIfExpression(n, "type", "jsp:plugin");
  +         throwErrorIfExpression(n, "code", "jsp:plugin");
  +         throwErrorIfExpression(n, "codebase", "jsp:plugin");
  +         throwErrorIfExpression(n, "align", "jsp:plugin");
  +         throwErrorIfExpression(n, "archive", "jsp:plugin");
  +         throwErrorIfExpression(n, "hspace", "jsp:plugin");
  +         throwErrorIfExpression(n, "jreversion", "jsp:plugin");
  +         throwErrorIfExpression(n, "name", "jsp:plugin");
  +         throwErrorIfExpression(n, "vspace", "jsp:plugin");
  +         throwErrorIfExpression(n, "nspluginurl", "jsp:plugin");
  +         throwErrorIfExpression(n, "iepluginurl", "jsp:plugin");
  +
            String type = n.getTextAttribute("type");
            if (type == null)
                err.jspError(n, "jsp.error.plugin.notype");
  @@ -891,6 +899,24 @@
                        n.getAttributeValue("omit-xml-declaration"));
        }
   
  +     public void visit(Node.InvokeAction n) throws JasperException {
  +
  +            JspUtil.checkAttributes("Invoke", n, invokeAttrs, err);
  +         if (n.getAttributeValue("var") != null
  +                 && n.getAttributeValue("varReader") != null) {
  +             err.jspError(n, "jsp.error.invoke.varAndVarReader");
  +         }
  +     }
  +
  +     public void visit(Node.DoBodyAction n) throws JasperException {
  +
  +            JspUtil.checkAttributes("DoBody", n, doBodyAttrs, err);
  +         if (n.getAttributeValue("var") != null
  +                 && n.getAttributeValue("varReader") != null) {
  +             err.jspError(n, "jsp.error.doBody.varAndVarReader");
  +         }
  +     }
  +
        /**
         * Preprocess attributes that can be expressions.  Expression
         * delimiters are stripped.
  @@ -992,21 +1018,18 @@
                return false;
        }
   
  -     public void visit(Node.InvokeAction n) throws JasperException {
  -
  -            JspUtil.checkAttributes("Invoke", n, invokeAttrs, err);
  -         if (n.getAttributeValue("var") != null
  -                 && n.getAttributeValue("varReader") != null) {
  -             err.jspError(n, "jsp.error.invoke.varAndVarReader");
  -         }
  -     }
  -
  -     public void visit(Node.DoBodyAction n) throws JasperException {
  -
  -            JspUtil.checkAttributes("DoBody", n, doBodyAttrs, err);
  -         if (n.getAttributeValue("var") != null
  -                 && n.getAttributeValue("varReader") != null) {
  -             err.jspError(n, "jsp.error.doBody.varAndVarReader");
  +     /*
  +      * Throws exception if the value of the attribute with the given
  +      * name in the given node is given as an RT or EL expression, but the
  +      * spec requires a static value.
  +      */
  +     private void throwErrorIfExpression(Node n, String attrName,
  +                                         String actionName)
  +                 throws JasperException {
  +         if (isExpression(n, n.getAttributes().getValue(attrName))) {
  +             err.jspError(n,
  +                          "jsp.error.attribute.standard.non_rt_with_expr",
  +                          attrName, actionName);
            }
        }
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to