|
17 | 17 | #include "Instance.hxx" |
18 | 18 | #include "util/StringAPI.hxx" |
19 | 19 | #include "util/ScopeExit.hxx" |
| 20 | +#include "util/StringCompare.hxx" |
20 | 21 | #include "tag/Settings.hxx" |
21 | 22 | #include "tag/ParseName.hxx" |
22 | 23 | #include "tag/Names.hxx" |
@@ -456,16 +457,31 @@ handle_sticker(Client &client, Request args, Response &r) |
456 | 457 | return handler->List(uri); |
457 | 458 |
|
458 | 459 | /* set */ |
459 | | - if (args.size() == 5 && StringIsEqual(cmd, "set")) |
| 460 | + if (args.size() == 5 && StringIsEqual(cmd, "set")) { |
| 461 | + if (StringIsEmpty(sticker_name)) { |
| 462 | + r.FmtError(ACK_ERROR_ARG, "empty sticker name"); |
| 463 | + return CommandResult::ERROR; |
| 464 | + } |
460 | 465 | return handler->Set(uri, sticker_name, args[4]); |
| 466 | + } |
461 | 467 |
|
462 | 468 | /* inc */ |
463 | | - if (args.size() == 5 && StringIsEqual(cmd, "inc")) |
| 469 | + if (args.size() == 5 && StringIsEqual(cmd, "inc")) { |
| 470 | + if (StringIsEmpty(sticker_name)) { |
| 471 | + r.FmtError(ACK_ERROR_ARG, "empty sticker name"); |
| 472 | + return CommandResult::ERROR; |
| 473 | + } |
464 | 474 | return handler->Inc(uri, sticker_name, args[4]); |
| 475 | + } |
465 | 476 |
|
466 | 477 | /* dec */ |
467 | | - if (args.size() == 5 && StringIsEqual(cmd, "dec")) |
| 478 | + if (args.size() == 5 && StringIsEqual(cmd, "dec")) { |
| 479 | + if (StringIsEmpty(sticker_name)) { |
| 480 | + r.FmtError(ACK_ERROR_ARG, "empty sticker name"); |
| 481 | + return CommandResult::ERROR; |
| 482 | + } |
468 | 483 | return handler->Dec(uri, sticker_name, args[4]); |
| 484 | + } |
469 | 485 |
|
470 | 486 | /* delete */ |
471 | 487 | if ((args.size() == 3 || args.size() == 4) && StringIsEqual(cmd, "delete")) |
|
0 commit comments