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

MiniMessage::deserialize throws StringIndexOutOfBoundsException when double quote is unclosed in tag argument (in lenient mode) #1011

Closed
homchom opened this issue Dec 19, 2023 · 0 comments · Fixed by #1012

Comments

@homchom
Copy link

homchom commented Dec 19, 2023

The documentation states that MiniMessage::deserialize should never throw by default, but when a double quote is left unclosed in the argument list of a tag (e.g. <hover:show_text_:">), a StringIndexOutOfBoundsException is thrown.

Here is the relevant stacktrace:

	at java.base/java.lang.String.substring(String.java:2709)
	at net.kyori.adventure.text.minimessage.internal.parser.TokenParser.unescape(TokenParser.java:620)
	at net.kyori.adventure.text.minimessage.internal.parser.node.TagPart.unquoteAndEscape(TagPart.java:109)
	at net.kyori.adventure.text.minimessage.internal.parser.node.TagPart.<init>(TagPart.java:53)
	at net.kyori.adventure.text.minimessage.internal.parser.match.StringResolvingMatchedTokenConsumer.accept(StringResolvingMatchedTokenConsumer.java:90)
	at net.kyori.adventure.text.minimessage.internal.parser.TokenParser.parseString(TokenParser.java:247)
	at net.kyori.adventure.text.minimessage.internal.parser.TokenParser.resolvePreProcessTags(TokenParser.java:112)
	at net.kyori.adventure.text.minimessage.MiniMessageParser.parseToTree(MiniMessageParser.java:195)
@zml2008 zml2008 added this to the 4.16.0 milestone Dec 19, 2023
@rymiel rymiel self-assigned this Dec 19, 2023
rymiel added a commit that referenced this issue Dec 19, 2023
The parser tries to un-quote tag parts surrounded by quotes, it does so
by checking if the first character of the tag part is a quote and the
last character is as well. However, things break if that first and last
character are actually the same character! A
StringIndexOutOfBoundsException is thrown later on.

This patch makes it so tag parts consisting of a single quote aren't
tried to be un-quoted, they stay as is

Fixes #1011
RedVortexDev added a commit to RedVortexDev/recode that referenced this issue Mar 26, 2024
KyoriPowered/adventure#1011 was fixed - no need to try-catch anymore (update adventure accordingly)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants