cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Crossley (JIRA)" <j...@apache.org>
Subject [jira] Updated: (COCOON-988) [PATCH] StreamGenerator can't handle multipart request parameters correctly
Date Wed, 01 Mar 2006 06:58:41 GMT
     [ http://issues.apache.org/jira/browse/COCOON-988?page=all ]

David Crossley updated COCOON-988:
----------------------------------

    Bugzilla Id:   (was: 25594)
     Other Info: [Patch available]
    Description: 
In the StreamGenerator class in line 140

String sXml = request.getParameter(parameter);
inputSource = new InputSource(new StringReader(sXml));

it is wrongly assumed that in case of multipart requests the xml data can 
be retrieved via the normal request.getParameter() Method. In fact this code
results in a sXml String containing something 
like "org.apache.cocoon.servlet.multipart.PartInMemory@4711" which is not the 
xml content and therefore cannot be parsed.

Instead it should read like:

Object xmlObject = request.get(parameter);
Reader  xmlReader = null;
if (xmlObject instanceof String){
  xmlReader  = new StringReader((String) xmlObject);
}
else if (xmlObject instanceof Part){
  xmlReader = new InputStreamReader(((Part) xmlObject).getInputStream());
}
else{
  throw new ProcessingException("Unknown request object encountred named " + 
parameter + " : " + xmlObject);
}
inputSource = new InputSource(xmlReader);

thx,

Gernot

  was:
In the StreamGenerator class in line 140

String sXml = request.getParameter(parameter);
inputSource = new InputSource(new StringReader(sXml));

it is wrongly assumed that in case of multipart requests the xml data can 
be retrieved via the normal request.getParameter() Method. In fact this code
results in a sXml String containing something 
like "org.apache.cocoon.servlet.multipart.PartInMemory@4711" which is not the 
xml content and therefore cannot be parsed.

Instead it should read like:

Object xmlObject = request.get(parameter);
Reader  xmlReader = null;
if (xmlObject instanceof String){
  xmlReader  = new StringReader((String) xmlObject);
}
else if (xmlObject instanceof Part){
  xmlReader = new InputStreamReader(((Part) xmlObject).getInputStream());
}
else{
  throw new ProcessingException("Unknown request object encountred named " + 
parameter + " : " + xmlObject);
}
inputSource = new InputSource(xmlReader);

thx,

Gernot


> [PATCH] StreamGenerator can't handle multipart request parameters correctly
> ---------------------------------------------------------------------------
>
>          Key: COCOON-988
>          URL: http://issues.apache.org/jira/browse/COCOON-988
>      Project: Cocoon
>         Type: Bug
>   Components: - Components: Sitemap
>     Versions: 2.2-dev (Current SVN)
>  Environment: Operating System: All
> Platform: All
>     Reporter: Gernot Koller
>     Assignee: Cocoon Developers Team

>
> In the StreamGenerator class in line 140
> String sXml = request.getParameter(parameter);
> inputSource = new InputSource(new StringReader(sXml));
> it is wrongly assumed that in case of multipart requests the xml data can 
> be retrieved via the normal request.getParameter() Method. In fact this code
> results in a sXml String containing something 
> like "org.apache.cocoon.servlet.multipart.PartInMemory@4711" which is not the 
> xml content and therefore cannot be parsed.
> Instead it should read like:
> Object xmlObject = request.get(parameter);
> Reader  xmlReader = null;
> if (xmlObject instanceof String){
>   xmlReader  = new StringReader((String) xmlObject);
> }
> else if (xmlObject instanceof Part){
>   xmlReader = new InputStreamReader(((Part) xmlObject).getInputStream());
> }
> else{
>   throw new ProcessingException("Unknown request object encountred named " + 
> parameter + " : " + xmlObject);
> }
> inputSource = new InputSource(xmlReader);
> thx,
> Gernot

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message