fix wrong uft-8 filenames on raw download, see issue #697

This commit is contained in:
Sebastian Sdorra
2015-04-18 22:11:34 +02:00
parent 518bf3fdab
commit 71291bd7ea
2 changed files with 26 additions and 7 deletions

View File

@@ -73,18 +73,18 @@ public final class HttpUtil
/** Field description */
public static final String ENCODING = "UTF-8";
/**
* location header
* @since 1.43
*/
public static final String HEADER_LOCATION = "Location";
/**
* content-length header
* @since 1.46
*/
public static final String HEADER_CONTENT_LENGTH = "Content-Length";
/**
* location header
* @since 1.43
*/
public static final String HEADER_LOCATION = "Location";
/**
* header for identifying the scm-manager client
* @since 1.19
@@ -296,6 +296,25 @@ public final class HttpUtil
}
}
/**
* Creates the value for the content-disposition attachment header. The method
* creates the filename as specified in rfc6266.
*
* @param name attachment name
* @see <a href="http://tools.ietf.org/html/rfc6266#section-5">rfc6266 section 5</a>
* @return value of content-disposition header
* @since 1.46
*/
public static String createContentDispositionAttachmentHeader(String name)
{
StringBuilder buffer = new StringBuilder("attachment; ");
buffer.append("filename=\"").append(name).append("\"; ");
buffer.append("filename*=utf-8''").append(encode(name));
return buffer.toString();
}
/**
* Method description
*

View File

@@ -1141,7 +1141,7 @@ public class RepositoryResource
*/
private String getContentDispositionName(String name)
{
return "attachment; filename=\"".concat(name).concat("\"");
return HttpUtil.createContentDispositionAttachmentHeader(name);
}
/**