Include quoted printable filename in ContentDisposition::toString

This commit ensures the ContentDisposition class prints the filename in
both in the regular filename parameter and the extended filename*
parameter (RFC 5987).
Quoted printable (RFC 2047) is used to encode any non-ASCII characters
in the regular filename parameter.

Closes gh-29861
This commit is contained in:
Arjen Poutsma
2023-02-01 13:38:19 +01:00
parent ebca9f726f
commit 58fbf60d2d
2 changed files with 56 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -249,7 +249,9 @@ class ContentDispositionTests {
.name("name")
.filename("中文.txt", StandardCharsets.UTF_8)
.build().toString())
.isEqualTo("form-data; name=\"name\"; filename*=UTF-8''%E4%B8%AD%E6%96%87.txt");
.isEqualTo("form-data; name=\"name\"; " +
"filename=\"=?UTF-8?Q?=E4=B8=AD=E6=96=87.txt?=\"; " +
"filename*=UTF-8''%E4%B8%AD%E6%96%87.txt");
}
@Test