1 Reply Latest reply on Jun 1, 2007 8:56 AM by Shane Bryzak

    bug with <s:upload> tag?encoding problem.

    liu lei Newbie

      I use <s:upload> tag to upload one file,whose name contains some Chinese charaters.
      something interesting happens.
      Our project's encoding is set to be UTF-8.
      My partner deploys the project in simplified Chinese windows xp whose local encoding is GBK.When he upload one file,whose name contains some Chinese charaters,he get the file name unrecognised in the program.
      While I deploy the project in the ubuntu7.04,whose local encoding is UTF-8.I just do the same things,but everything is fine.
      The <s:upload> tag that we use as below

      <s:fileUpload data="#{attachment.data}" contentType="#{attachment.contentType}" fileName="#{attachment.name}" style="width:100;" />

      We debug into the source code,find that when the request reach org.jboss.seam.web.MultipartRequest.parseRequest() method
      ,the charator is aready unrecognised.
      Below is the code which seams to have some bug.
      case HEADERS:
       {
       if (checkSequence(buffer, i, CR_LF))
      {
       parseParams(new String(buffer, pos, i - pos - 1), ";", headers);

      We modify the code to be
      if(encoding==null)
       parseParams(new String(buffer, pos, i - pos - 1), ";", headers);
       else
       parseParams(new String(buffer, pos, i - pos - 1,encoding), ";", headers);

      Now both in windows xp and ubuntu,we get the file name correctly.
      I suppose what I find to be useful with others who do love Seam.
      Thank you.