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

Bandaid fix for single quotes in command args #6936

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/ch/njol/skript/command/CommandUsage.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public class CommandUsage {
*/
public CommandUsage(@Nullable VariableString usage, String defaultUsage) {
if (usage == null) {
// Manually escape quotes. This is not a good solution, as it doesn't handle many other issues, like % in
// commands, but in lieu of re-writing the argument parser and command logic completely, I believe this is
// a decent stop-gap measure for using " in commands.
defaultUsage = VariableString.quote(defaultUsage);
usage = VariableString.newInstance(defaultUsage);
assert usage != null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
command single-quotes-in-commands ["<text="success 2">"]:
trigger:
set {sqic::output} to arg
Pikachu920 marked this conversation as resolved.
Show resolved Hide resolved

test "single-quotes-in-commands":
execute console command "single-quotes-in-commands ""success 1"""
sovdeeth marked this conversation as resolved.
Show resolved Hide resolved
assert {sqic::output} is "success 1" with "failed to parse arg in quotes"
execute console command "single-quotes-in-commands"
assert {sqic::output} is "success 2" with "failed to use default arg"
delete {sqic::output}