소스 검색

* Added confirmation for using 'set' on list variables without using the list functions. (#118)

svn: 2297
Bryan Drewery 21 년 전
부모
커밋
d6996e514d
2개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 1 0
      doc/UPDATES
  2. 13 0
      src/set.c

+ 1 - 0
doc/UPDATES

@@ -45,6 +45,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Fixed cmd_chattr saving userfile when no changes were made. (#123)
 * Fixed cmd_chattr displaying flags for higher users, therefore bypassing 'whois' restrictions. (#123)
 * Added examples on how to use cmd_set in the helpfile. (#118)
+* Added confirmation for using 'set' on list variables without using the list functions. (#118)
 
 1.2.4
 * Fixed cmd_botset not displaying botnick.

+ 13 - 0
src/set.c

@@ -623,6 +623,12 @@ void cmd_set_real(const char *botnick, int idx, char *par)
   char *name = NULL;
   const char *data = NULL, *botdata = NULL;
   int list = 0, i = 0;
+  bool notyes = 1;
+
+  if (par[0] && !egg_strncasecmp(par, "-yes", 4)) {
+    notyes = 0;
+    newsplit(&par);
+  }
 
   if (botnick)
     putlog(LOG_CMDS, "*", "#%s# botset %s %s", dcc[idx].nick, botnick, par);
@@ -718,6 +724,13 @@ void cmd_set_real(const char *botnick, int idx, char *par)
       i++;
     }
   } else { // need to set it!
+    if (!list && var->flags & VAR_LIST) {
+      if (notyes) {
+        dprintf(idx, "Using non-list functions on a list variable can be dangerous, please retype with -YES if you're sure:\n");
+        dprintf(idx, "%s%sset -YES %s ...\n", settings.dcc_prefix, botnick ? "bot" : "", var->name);
+        return;
+      }
+    }
     if (botnick) {
       if (var->flags & VAR_NOLOC) {
         dprintf(idx, "Sorry, cannot set '%s' locally.\n", var->name);