Skip to content

Commit

Permalink
tg_cpphost: flash cmd: Don't allow newlines in zipname
Browse files Browse the repository at this point in the history
  • Loading branch information
Royna2544 committed Nov 21, 2023
1 parent 1f3c4a6 commit ebf11ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ int main(void) {
}
parseExtArgs(message, msg);
}

for (const auto c : msg) {
if (c == '\n') {
bot_sendReplyMessage(bot, message, "Zip names shouldn't have newlines");
return;
}
}
if (!std::regex_match(StringTools::split(msg, '\n').front(), kFlashTextRegEX)) {
std::replace(msg.begin(), msg.end(), ' ', '_');
std::replace(msg.begin(), msg.end(), '\n', ' ');
if (!StringTools::endsWith(msg, kZipExtentionSuffix)) {
msg += kZipExtentionSuffix;
}
Expand Down

0 comments on commit ebf11ac

Please sign in to comment.