Skip to content

Commit 959677b

Browse files
committed
copy
1 parent 1017f7f commit 959677b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/test/java/io/fusionauth/http/util/HTTPToolsTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void parseEncodedData() {
100100
assertEncodedData("é", "é", StandardCharsets.UTF_8);
101101
assertEncodedData("Héllö", "Héllö", StandardCharsets.UTF_8);
102102

103-
// These UTF-8 double byte values are outside ISO-88559-1, so we should expect them to not render correctly. See next test.
103+
// These UTF-8 double byte values are outside ISO-8559-1, so we should expect them to not render correctly. See next test.
104104
assertHexValue("😎", "D83D DE0E");
105105
assertHexValue("€", "20AC");
106106

@@ -121,16 +121,16 @@ public void parseEncodedData() {
121121
assertEncodedData("Héllö", "H�ll�", StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8);
122122
assertEncodedData("Hello world", "Hello world", StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8);
123123
// The é and the ö will fail to render because while this character exists in both character sets, they are encoded differently.
124-
// - So we should expec them to render incorrectly.
124+
// - So we should expect them to render incorrectly.
125125
// - See below, this is just here to validate why the above assertions are accurate.
126126
assertHexValue("Héllö", "48 E9 6C 6C F6 ", StandardCharsets.ISO_8859_1);
127127
assertHexValue("Héllö", "48 C3 A9 6C 6C C3 B6", StandardCharsets.UTF_8);
128128

129-
// - Reverse
129+
// - Reverse order
130130
assertEncodedData("Héllö", "Héllö", StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1);
131131
assertEncodedData("Hello world", "Hello world", StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1);
132132
// The é and the ö will fail to render because while this character exists in both character sets, they are encoded differently.
133-
// - So we should expec them to render incorrectly.
133+
// - So we should expect them to render incorrectly.
134134
// - See below, this is just here to validate why the above assertions are accurate.
135135
assertHexValue("é", "C3 A9", StandardCharsets.UTF_8);
136136
assertHexValue("é", "C3 A9", StandardCharsets.ISO_8859_1);
@@ -140,8 +140,6 @@ public void parseEncodedData() {
140140

141141
@Test
142142
public void parseHeaderValue() {
143-
String iso = "åpple";
144-
String utf = "😁";
145143
assertEquals(HTTPTools.parseHeaderValue("text/plain; charset=iso8859-1"), new HeaderValue("text/plain", Map.of("charset", "iso8859-1")));
146144
assertEquals(HTTPTools.parseHeaderValue("text/plain; charset=iso-8859-1"), new HeaderValue("text/plain", Map.of("charset", "iso-8859-1")));
147145
assertEquals(HTTPTools.parseHeaderValue("text/plain; charset=iso8859-1; boundary=FOOBAR"), new HeaderValue("text/plain", Map.of("boundary", "FOOBAR", "charset", "iso8859-1")));
@@ -156,6 +154,9 @@ public void parseHeaderValue() {
156154
assertEquals(HTTPTools.parseHeaderValue("form-data; filename*=ISO-8859-1'en'foo.jpg"), new HeaderValue("form-data", Map.of("filename", "foo.jpg")));
157155
assertEquals(HTTPTools.parseHeaderValue("form-data; filename=ignore.jpg; filename*=ISO-8859-1'en'foo.jpg"), new HeaderValue("form-data", Map.of("filename", "foo.jpg")));
158156

157+
String iso = "åpple";
158+
String utf = "😁";
159+
159160
// Encoded
160161
assertEquals(HTTPTools.parseHeaderValue("form-data; filename*=ISO8859-1'en'" + URLEncoder.encode(iso, StandardCharsets.ISO_8859_1)), new HeaderValue("form-data", Map.of("filename", iso)));
161162
assertEquals(HTTPTools.parseHeaderValue("form-data; filename*=ISO-8859-1'en'" + URLEncoder.encode(iso, StandardCharsets.ISO_8859_1)), new HeaderValue("form-data", Map.of("filename", iso)));

0 commit comments

Comments
 (0)