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

wrong charset encoding in FormEncodingProvider

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.12
    • Fix Version/s: 2.4.10, 2.5.6, 2.6.3, 2.7
    • Component/s: Core
    • Labels:
      None
    • Estimated Complexity:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: