Skip to content

Commit

Permalink
Merge pull request #1012 from KyoriPowered/fix/mm-single-quote
Browse files Browse the repository at this point in the history
minimessage: Fix exception with single quote as tag part
  • Loading branch information
rymiel authored Dec 19, 2023
2 parents ee89b80 + 3e0b4eb commit 87fc5dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ public TagPart(
endIndex--;
}

if (startIndex > endIndex) {
// We were given only a single quote that doesn't terminate, we can't unescape it
return text.substring(start, end);
}

return TokenParser.unescape(text, startIndex, endIndex, i -> i == firstChar || i == TokenParser.ESCAPE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,4 +544,13 @@ public boolean has(final @NotNull String name) {

this.assertParsedEquals(expected, input, alwaysMatchingResolver);
}

// https://github.com/KyoriPowered/adventure/issues/1011
@Test
void testNonTerminatingQuoteArgument() {
final String input = "<hover:show_text_:\">";
final Component expected = Component.text(input);

this.assertParsedEquals(expected, input);
}
}

0 comments on commit 87fc5dc

Please sign in to comment.