luehe       2002/12/09 14:26:10

  Modified:    jasper2/src/share/org/apache/jasper/compiler Validator.java
  Log:
  When verifying that a custom action does not have any invalid
  attributes, take the attributes' URI into account.
  
  Revision  Changes    Path
  1.56      +28 -4     
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.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- Validator.java    8 Nov 2002 19:55:47 -0000       1.55
  +++ Validator.java    9 Dec 2002 22:26:10 -0000       1.56
  @@ -361,6 +361,7 @@
        private ErrorDispatcher err;
        private TagInfo tagInfo;
           private ClassLoader loader;
  +     private Hashtable taglibs;
   
        // A FunctionMapper, used to validate EL expressions.
           private FunctionMapper functionMapper;
  @@ -442,6 +443,7 @@
         */
        ValidateVisitor(Compiler compiler) {
            this.pageInfo = compiler.getPageInfo();
  +         this.taglibs = pageInfo.getTagLibraries();
            this.err = compiler.getErrorDispatcher();
            this.tagInfo = compiler.getCompilationContext().getTagInfo();
            this.loader = compiler.getCompilationContext().getClassLoader();
  @@ -679,10 +681,32 @@
                = new Node.JspAttribute[attrs.getLength()
                                       + namedAttributeNodes.size()];
            Hashtable tagDataAttrs = new Hashtable(attrs.getLength());
  +         TagLibraryInfo tagLibInfo =
  +             (TagLibraryInfo) taglibs.get(n.getPrefix());
  +         String uri = tagLibInfo.getURI();
            for (int i=0; i<attrs.getLength(); i++) {
                boolean found = false;
                for (int j=0; tldAttrs != null && j<tldAttrs.length; j++) {
  -                 if (attrs.getQName(i).equals(tldAttrs[j].getName())) {
  +                 /*
  +                  * A custom action and its declared attributes always
  +                  * belong to the same namespace, which is identified by
  +                  * the prefix name of the custom tag invocation.
  +                  * For example, in this invocation:
  +                  *     <my:test a="1" b="2" c="3"/>, the action
  +                  * "test" and its attributes "a", "b", and "c" all belong
  +                  * to the namespace identified by the prefix "my".
  +                  * The above invocation would be equivalent to:
  +                  *     <my:test my:a="1" my:b="2" my:c="3"/>
  +                  * An action attribute may have a prefix different from
  +                  * that of the action invocation only if the underlying
  +                  * tag handler supports dynamic attributes, in which case
  +                  * the attribute with the different prefix is considered a
  +                  * dynamic attribute.
  +                  */
  +                 if (attrs.getLocalName(i).equals(tldAttrs[j].getName())
  +                         && (attrs.getURI(i) == null
  +                             || attrs.getURI(i).length() == 0
  +                             || attrs.getURI(i) == uri)) {
                        if (tldAttrs[j].canBeRequestTime()) {
                               Class expectedType = String.class;
                               try {
  
  
  

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

Reply via email to