Skip to content

Commit 6afcf79

Browse files
authored
Merge pull request #1150 from amvanbaren/issue-826
[Bug] Emoji is invalid
2 parents 2fe5313 + 327e8d1 commit 6afcf79

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

server/src/main/java/org/eclipse/openvsx/ExtensionValidator.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919

2020
import java.net.MalformedURLException;
2121
import java.net.URL;
22-
import java.util.ArrayList;
23-
import java.util.List;
24-
import java.util.Objects;
25-
import java.util.Optional;
22+
import java.util.*;
2623
import java.util.function.Predicate;
2724
import java.util.regex.Pattern;
2825

@@ -62,7 +59,8 @@ private void validateDisplayName(String displayName, int limit, List<Issue> issu
6259

6360
private void validateDescription(String description, int limit, List<Issue> issues) {
6461
var field = "description";
65-
checkCharacters(description, field, issues);
62+
var zeroWidthJoinerChar = '\u200D'; // character that allows combining multiple emojis into one (https://en.wikipedia.org/wiki/Zero-width_joiner)
63+
checkCharacters(description, field, issues, List.of(zeroWidthJoinerChar));
6664
checkFieldSize(description, limit, field, issues);
6765
}
6866

@@ -164,11 +162,21 @@ private void checkTargetPlatform(String targetPlatform, List<Issue> issues) {
164162
}
165163

166164
private void checkCharacters(String value, String field, List<Issue> issues) {
165+
checkCharacters(value, field, issues, Collections.emptyList());
166+
}
167+
168+
private void checkCharacters(String value, String field, List<Issue> issues, List<Character> allowedChars) {
167169
if (value == null) {
168170
return;
169171
}
172+
170173
for (var i = 0; i < value.length(); i++) {
171-
var type = Character.getType(value.charAt(i));
174+
var character = value.charAt(i);
175+
if(allowedChars.contains(character)) {
176+
continue;
177+
}
178+
179+
var type = Character.getType(character);
172180
if (type == Character.CONTROL || type == Character.FORMAT
173181
|| type == Character.UNASSIGNED || type == Character.PRIVATE_USE
174182
|| type == Character.LINE_SEPARATOR || type == Character.PARAGRAPH_SEPARATOR) {

server/src/test/java/org/eclipse/openvsx/ExtensionValidatorTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ void testGitProtocol() {
109109
assertThat(issues).isEmpty();
110110
}
111111

112+
@Test
113+
void testDescription() {
114+
var extension = new ExtensionVersion();
115+
extension.setTargetPlatform(TargetPlatform.NAME_UNIVERSAL);
116+
extension.setVersion("1.0.0");
117+
extension.setDescription("\uD83C\uDFC3\u200D\uFE0F Jump/Select to the Start/End of a word in VSCode");
118+
var issues = validator.validateMetadata(extension);
119+
assertThat(issues).isEmpty();
120+
}
121+
112122
@TestConfiguration
113123
static class TestConfig {
114124
@Bean

0 commit comments

Comments
 (0)