3 Replies Latest reply on Nov 4, 2004 10:58 AM by Marco Ciancimino

    Multipart encoding problem

    Marco Ciancimino Newbie

      Hi developers,
      there is a problem in nukes1.1RC3. Take a look at the contructor of org.jboss.nukes.servlet.MultipartRequest. The parameters values are extracted from upload fields with the standard encoding, ignoring the configured character set. In fact, the zero parameters version of org.apache.commons.fileupload.FileItem is called.

      This is the code (with my comments in bold):

      public MultipartRequest(HttpServletRequest request, int sizeMax)
      throws FileUploadException
      {
      super(request);

      // Create a new file upload handler
      DiskFileUpload upload = new DiskFileUpload();

      // Set upload parameters
      upload.setSizeMax(sizeMax);
      upload.setSizeThreshold(sizeMax);
      upload.setRepositoryPath(System.getProperty("java.io.tmpdir"));

      // Get request parameters
      for (Enumeration en = request.getParameterNames();en.hasMoreElements();)
      {
      String name = (String)en.nextElement();
      parameters.put(name, request.getParameterValues(name));
      }

      // Merge with upload fields
      for (Iterator i = upload.parseRequest(request).iterator();i.hasNext();)
      {
      FileItem item = (FileItem)i.next();
      if (item.isFormField())
      {
      // NEXT LINE IS PROBABLY WRONG
      parameters.put(item.getFieldName(), new String[]{item.getString()});
      }
      else
      {
      files.put(item.getFieldName(), new UploadedFile(item.getContentType(), item.get()));
      }
      }
      }

      Thanks in advance,
      Marco