Skip to content

Commit

Permalink
Merge pull request quarkusio#34804 from gastaldi/emoji
Browse files Browse the repository at this point in the history
Encode multi char code points correctly in RestEasy Reactive
  • Loading branch information
geoand authored Jul 18, 2023
2 parents 11f4ee5 + 054adb6 commit 581cec3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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));
}
}

0 comments on commit 581cec3

Please sign in to comment.