Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4499

wrong charset encoding in FormEncodingProvider

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.12
    • 2.4.10, 2.5.6, 2.6.3, 2.7
    • Core
    • None
    • Unknown

    Description

      org.apache.cxf.jaxrs.provider.FormEncodingProvider

      	public void writeTo(Object obj, Class<?> c, Type t, Annotation[] anns,
      			MediaType mt, MultivaluedMap<String, Object> headers,
      			OutputStream os) throws IOException, WebApplicationException {
      
      
      
      
      // ....... else .....
      
      		
              MultivaluedMap<String, String> map = (MultivaluedMap<String, String>)obj;
              boolean encoded = AnnotationUtils.getAnnotation(anns, Encoded.class) != null;
              
              String encoding = HttpUtils.getSetEncoding(mt, headers, "UTF-8");  
              
              for (Iterator<Map.Entry<String, List<String>>> it = map.entrySet().iterator(); it.hasNext();) {
                  Map.Entry<String, List<String>> entry = it.next();
                  for (Iterator<String> entryIterator = entry.getValue().iterator(); entryIterator.hasNext();) {
                      String value = entryIterator.next();
                      os.write(entry.getKey().getBytes(encoding));
                      os.write('=');
                      String data = encoded ? value : urlEncode(value); // <--- here urlEncode always use utf-8 ,  encoding get losted here
                      os.write(data.getBytes(encoding));
                      if (entryIterator.hasNext() || it.hasNext()) {
                          os.write('&');
                      }
                  }
      
              }
      

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            farmer1992 boshi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: