Skip to content

Commit f91953e

Browse files
authored
Fixed bug with format injection (#615)
1 parent ebf3673 commit f91953e

File tree

1 file changed

+5
-4
lines changed
  • application/src/main/java/org/togetherjava/tjbot/commands/help

1 file changed

+5
-4
lines changed

application/src/main/java/org/togetherjava/tjbot/commands/help/AskCommand.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,11 @@ private RestAction<Message> sendInitialMessage(Guild guild, ThreadChannel thread
136136
.map(role -> " (%s)".formatted(role.getAsMention()))
137137
.orElse("");
138138

139-
String contentPattern = "%s has a question about '**%s**'%%s and will send the details now."
140-
.formatted(author.getAsMention(), title);
141-
String contentWithoutRole = contentPattern.formatted("");
142-
String contentWithRole = contentPattern.formatted(roleMentionDescription);
139+
String contentPrefix =
140+
"%s has a question about '**%s**'".formatted(author.getAsMention(), title);
141+
String contentSuffix = " and will send the details now.";
142+
String contentWithoutRole = contentPrefix + contentSuffix;
143+
String contentWithRole = contentPrefix + roleMentionDescription + contentSuffix;
143144

144145
// We want to invite all members of a role, but without hard-pinging them. However,
145146
// manually inviting them is cumbersome and can hit rate limits.

0 commit comments

Comments
 (0)