Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode multi char code points correctly in RestEasy Reactive #34804

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ protected static String encodeFromArray(String segment, String[] encodingMap, bo
result.append(currentChar);
continue;
}
if (Character.isHighSurrogate(currentChar)) {
String part = segment.substring(i, i + 2);
result.append(URLEncoder.encode(part, StandardCharsets.UTF_8));
++i;
continue;
}
String encoding = encode(currentChar, encodingMap);
if (encoding == null) {
result.append(currentChar);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.jboss.resteasy.reactive.common.util;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

import org.junit.jupiter.api.Test;

class EncodeTest {
@Test
void encodeEmoji() {
String emoji = "\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00\uD83D\uDE00";
String encodedEmoji = URLEncoder.encode(emoji, StandardCharsets.UTF_8);
assertEquals(encodedEmoji, Encode.encodePath(emoji));
assertEquals(encodedEmoji, Encode.encodeQueryParam(emoji));
}
}