fix #2786 Optimized Content-Disposition handling: use 'filename*' only for non-ASCII names.
This commit is contained in:
parent
5b7b17ff4b
commit
d38211eadf
1 changed files with 10 additions and 1 deletions
|
@ -745,7 +745,16 @@ public class ViewHelper {
|
|||
}
|
||||
|
||||
final String encodedName = URLEncoder.encode(name, Constants.UTF_8).replace("+", "%20");
|
||||
response.header(CONTENT_DISPOSITION, contentDispositionType + "; filename=\"" + name + "\"; filename*=utf-8''" + encodedName);
|
||||
final String contentDispositionValue;
|
||||
if (name.equals(encodedName)) {
|
||||
contentDispositionValue = contentDispositionType + "; filename=\"" + name + "\"";
|
||||
} else {
|
||||
contentDispositionValue = contentDispositionType + "; filename*=utf-8''" + encodedName;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("ResponseHeader: {}: {}", CONTENT_DISPOSITION, contentDispositionValue);
|
||||
}
|
||||
response.header(CONTENT_DISPOSITION, contentDispositionValue);
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to write a filename: {}", responseData, e);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue