luehe 2003/01/08 10:42:43 Modified: jasper2/src/share/org/apache/jasper/compiler Generator.java Node.java Validator.java Log: Fixed 15854: Unable to provide a qname attribute value to the name attribute of the jsp:attribute action. Revision Changes Path 1.145 +11 -11 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java Index: Generator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v retrieving revision 1.144 retrieving revision 1.145 diff -u -r1.144 -r1.145 --- Generator.java 6 Jan 2003 18:57:14 -0000 1.144 +++ Generator.java 8 Jan 2003 18:42:42 -0000 1.145 @@ -2388,17 +2388,17 @@ } } - String attrName = attr.getName(); + String localName = attr.getLocalName(); Method m = null; Class[] c = null; if (attr.isDynamic()) { c = OBJECT_CLASS; } else { - m = handlerInfo.getSetterMethod(attrName); + m = handlerInfo.getSetterMethod(localName); if (m == null) { err.jspError(n, "jsp.error.unable.to_find_method", - attrName); + attr.getName()); } c = m.getParameterTypes(); // XXX assert(c.length > 0) @@ -2410,8 +2410,8 @@ if (!n.checkIfAttributeIsJspFragment(attr.getName()) && !attr.isDynamic()) { attrValue = convertString( - c[0], attrValue, attrName, - handlerInfo.getPropertyEditorClass(attrName), + c[0], attrValue, localName, + handlerInfo.getPropertyEditorClass(localName), true); } } else if (attr.isELInterpreterInput()) { @@ -2420,8 +2420,8 @@ attrValue, c[0], n.getPrefix(), "_jspx_fnmap", false ); } else { attrValue = convertString( - c[0], attrValue, attrName, - handlerInfo.getPropertyEditorClass(attrName), + c[0], attrValue, localName, + handlerInfo.getPropertyEditorClass(localName), false); } return attrValue; @@ -2503,7 +2503,7 @@ } else { out.printin(tagHandlerVar); out.print("."); - out.print(handlerInfo.getSetterMethod(attrs[i].getName()).getName()); + out.print(handlerInfo.getSetterMethod(attrs[i].getLocalName()).getName()); out.print("("); out.print(attrValue); out.println(");"); 1.51 +37 -11 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java Index: Node.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- Node.java 6 Jan 2003 18:57:15 -0000 1.50 +++ Node.java 8 Jan 2003 18:42:43 -0000 1.51 @@ -175,7 +175,15 @@ int numChildNodes = nodes.size(); for( int i = 0; i < numChildNodes; i++ ) { NamedAttribute na = (NamedAttribute)nodes.getNode( i ); - if( na.getName().equals( name ) ) { + boolean found = false; + int index = name.indexOf(':'); + if (index != -1) { + // qualified name + found = na.getName().equals(name); + } else { + found = na.getLocalName().equals(name); + } + if (found) { result = na; break; } @@ -1312,15 +1320,25 @@ private boolean trim = true; private ChildInfo childInfo; + private String name; + private String localName; + private String prefix; public NamedAttribute( Attributes attrs, Mark start, Node parent) { super( attrs, start, parent ); - this.temporaryVariableName = JspUtil.nextTemporaryVariableName(); + temporaryVariableName = JspUtil.nextTemporaryVariableName(); if( "false".equals( this.getAttributeValue( "trim" ) ) ) { // (if null or true, leave default of true) trim = false; } - this.childInfo = new ChildInfo(); + childInfo = new ChildInfo(); + name = this.getAttributeValue("name"); + localName = name; + int index = name.indexOf(':'); + if (index != -1) { + prefix = name.substring(0, index); + localName = name.substring(index+1); + } } public void accept(Visitor v) throws JasperException { @@ -1328,7 +1346,15 @@ } public String getName() { - return this.getAttributeValue( "name" ); + return this.name; + } + + public String getLocalName() { + return this.localName; + } + + public String getPrefix() { + return this.prefix; } public ChildInfo getChildInfo() { @@ -1497,11 +1523,11 @@ * named attribute. In this case, we have to store the nodes of * the body of the attribute. */ - JspAttribute(NamedAttribute namedAttributeNode, boolean dyn) { - this.qName = namedAttributeNode.getName(); - this.localName = this.qName; + JspAttribute(NamedAttribute na, boolean dyn) { + this.qName = na.getName(); + this.localName = na.getLocalName(); this.value = null; - this.namedAttributeNode = namedAttributeNode; + this.namedAttributeNode = na; this.expression = false; this.el = false; this.dynamic = dyn; 1.65 +28 -9 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.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- Validator.java 6 Jan 2003 18:57:15 -0000 1.64 +++ Validator.java 8 Jan 2003 18:42:43 -0000 1.65 @@ -678,17 +678,26 @@ err.jspError(n, "jsp.error.dynamic.attributes.not.implemented", n.getName()); } + + // Get custom actions's namespace, which is used to validate the + // namespaces of any custom action attributes with qualified names + String customActionUri = + ((TagLibraryInfo) taglibs.get(n.getPrefix())).getURI(); /* * Make sure all required attributes are present, either as * attributes or named attributes (<jsp:attribute>). - * Also Make sure that the same attribute is not specified in + * Also make sure that the same attribute is not specified in * both attributes or named attributes. */ TagAttributeInfo[] tldAttrs = tagInfo.getAttributes(); Attributes attrs = n.getAttributes(); for (int i=0; i<tldAttrs.length; i++) { String attr = attrs.getValue(tldAttrs[i].getName()); + if (attr == null) { + attr = attrs.getValue(customActionUri, + tldAttrs[i].getName()); + } Node.NamedAttribute jspAttr = n.getNamedAttributeNode(tldAttrs[i].getName()); @@ -711,9 +720,6 @@ = 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++) { @@ -736,7 +742,7 @@ if (attrs.getLocalName(i).equals(tldAttrs[j].getName()) && (attrs.getURI(i) == null || attrs.getURI(i).length() == 0 - || attrs.getURI(i) == uri)) { + || attrs.getURI(i) == customActionUri)) { if (tldAttrs[j].canBeRequestTime()) { Class expectedType = String.class; try { @@ -815,9 +821,22 @@ for (int i=0; i<namedAttributeNodes.size(); i++) { Node.NamedAttribute na = (Node.NamedAttribute)namedAttributeNodes.getNode( i ); + String uri = ""; + if (na.getPrefix() != null) { + TagLibraryInfo tagLibInfo = + (TagLibraryInfo) taglibs.get(na.getPrefix()); + if (tagLibInfo == null) { + err.jspError(n, "jsp.error.attribute.invalidPrefix", + na.getPrefix()); + } + uri = tagLibInfo.getURI(); + } boolean found = false; for (int j=0; j<tldAttrs.length; j++) { - if (na.getName().equals(tldAttrs[j].getName())) { + // See above comment about namespace matches + if (na.getLocalName().equals(tldAttrs[j].getName()) + && (uri == null || uri.length() == 0 + || uri == customActionUri)) { jspAttrs[attrs.getLength() + i] = new Node.JspAttribute(na, false); NamedAttributeVisitor nav = null;
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>