tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 35252] New: - jasper2 produced malformed expanded XML view
Date Tue, 07 Jun 2005 05:36:49 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35252>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35252

           Summary: jasper2 produced malformed expanded XML view
           Product: Tomcat 5
           Version: 5.0.28
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Jasper
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: akolkar@us.ibm.com


The FirstPassVisitor in org.apache.jasper.compiler.PageDataImpl adds all 
attributes (except "version") of jsp:root elements of included JSPs to 
jsp:root of expanded XML view. The expanded XML view is thus, often malformed.

Any entity, such as a TagLibraryValidator, that tries to subsequently parse 
the malformed expanded XML view, fails. For example:

main.jspx (using Jakarta Taglibs "standard" JSTL impl):
--------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" 
 xmlns:c="http://java.sun.com/jsp/jstl/core" version="2.0" >
    <jsp:directive.include file="one.jspx"/>
</jsp:root>

where one.jspx is:
----------------------
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" />

gives:
<top-of-stack-trace>
org.apache.jasper.JasperException: <h3>Validation error messages from 
TagLibraryValidator for c</h3><p>null: org.xml.sax.SAXParseException: 
Attribute "jsp" bound to namespace "http://www.w3.org/2000/xmlns/" was already 
specified for element "jsp:root".</p>
</top-of-stack-trace>

as, in this scenario, attribute xmlns:jsp gets added twice.

[Problem reported by "Dino Klein" <zagzag@speakeasy.net> on taglibs-dev@j.a.o]

I'm proposing a patch that causes FirstPassVisitor to only add those 
attributes to the jsp:root of the expanded XML view that have not been already 
added.

Index: PageDataImpl.java
===================================================================
RCS file: /usr/local/cvsroot/apache/jakarta-tomcat-5.0.28-src/jakarta-tomcat-
jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v
retrieving revision 1.1
diff -c -r1.1 PageDataImpl.java
*** PageDataImpl.java	7 Jun 2005 02:29:52 -0000	1.1
--- PageDataImpl.java	7 Jun 2005 02:33:19 -0000
***************
*** 205,218 ****
  	    if (attrs != null) {
  		int len = attrs.getLength();
  		for (int i=0; i<len; i++) {
! 		    if ("version".equals(attrs.getQName(i))) {
  			continue;
  		    }
! 		    rootAttrs.addAttribute(attrs.getURI(i),
  					   attrs.getLocalName(i),
! 					   attrs.getQName(i),
  					   attrs.getType(i),
  					   attrs.getValue(i));
  		}
  	    }
  	}
--- 205,221 ----
  	    if (attrs != null) {
  		int len = attrs.getLength();
  		for (int i=0; i<len; i++) {
! 		    String qName = attrs.getQName(i);
! 		    if ("version".equals(qName)) {
  			continue;
  		    }
! 		    if (rootAttrs.getIndex(qName) == -1) {
! 		    	rootAttrs.addAttribute(attrs.getURI(i),
  					   attrs.getLocalName(i),
! 					   qName,
  					   attrs.getType(i),
  					   attrs.getValue(i));
+ 		    }
  		}
  	    }
  	}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message