Skip to content

Commit

Permalink
Fix string replacement in tournaments
Browse files Browse the repository at this point in the history
  • Loading branch information
Zarel committed Oct 29, 2018
1 parent 0553f42 commit 78c34cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tournaments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1039,8 +1039,10 @@ const commands = {
if (result.charAt(0) === '1') {
connection.popup("Your team is valid for this tournament.");
} else {
const format = Dex.getFormat(tournament.originalFormat).name.replace(/\[/g, '\\[').replace(/\]/g, '\\]');
connection.popup(`Your team was rejected for the following reasons:\n\n- ${result.slice(1).replace(/\n/g, '\n- ').replace(new RegExp(format, 'g'), 'this tournament')}`);
const formatName = Dex.getFormat(tournament.originalFormat).name;
// split/join is the easiest way to do a find/replace with an untrusted string, sadly
const reasons = result.slice(1).split(formatName).join('this tournament');
connection.popup(`Your team was rejected for the following reasons:\n\n- ${reasons.replace(/\n/g, '\n- ')}`);
}
});
},
Expand Down

0 comments on commit 78c34cb

Please sign in to comment.