[ 
https://issues.apache.org/jira/browse/HTTPCLIENT-1859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16059170#comment-16059170
 ] 

Karl Wright commented on HTTPCLIENT-1859:
-----------------------------------------

Here's the method that needs to be called to escape both the header "name" 
field and the header "filename" field:

{code}
  private static String encodeForHeader(final String headerName) {
    if (headerName == null) {
      return null;
    }
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < headerName.length(); i++) {
      final char x = headerName.charAt(i);
      if (x == '"' || x == '\\' || x == '\r') {
        sb.append("\\");
      }
      sb.append(x);
    }
    return sb.toString();
  }
{code}


> FormBodyPartBuilder.java does not properly escape the name and filename 
> subfields in the ContentDisposition header
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1859
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1859
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>            Reporter: Karl Wright
>            Assignee: Karl Wright
>
> The ContentDisposition header, used in multi-part forms, has a name and 
> filename subfield; these need to be escaped using unix-standard backslash 
> character stuffing, but FormBodyPartBuilder does not currently do this.  It 
> should.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to