Procházet zdrojové kódy

* Sanitize cmd_set locally as well as remotely

Before, it was only sanitizing set input when actually setting
the variable. Now it will do it locally as well when
setting it for bots.
Bryan Drewery před 17 roky
rodič
revize
6865e6e873
2 změnil soubory, kde provedl 14 přidání a 0 odebrání
  1. 2 0
      doc/UPDATES
  2. 12 0
      src/set.c

+ 2 - 0
doc/UPDATES

@@ -1,3 +1,5 @@
+* Sanitize cmd_set input locally as well as remotely
+
 1.2.16 - http://wraith.botpack.net/milestone/1.2.16
 * Add 'set altchars' so that alternative characters used for nicks can be changed. (fixes #418)
 * Fix channels added by cmd_slowjoin not having the user who added them associated with the channel.

+ 12 - 0
src/set.c

@@ -1052,11 +1052,23 @@ int cmd_set_real(const char *botnick, int idx, char *par)
       dprintf(idx, "Failed to modify %s list.\n", var->name);
       return 0;
     } else {
+      /* If no data or data is not -
+         sanitize the data */
+      char *sdata = NULL;
+      /* Make a temporary to free at the end */
+      if (data && strcmp(data, "-") && (!var->def || (var->def && strcmp(data, var->def)))) {
+        sdata = var_sanitize(var, data);
+        data = sdata;
+      }
+
       var_set(var, botnick, data);
       if (botnick)
         var_set_userentry(botnick, name, data);
 
       dprintf(idx, "%s: %s\n", name, botnick ? (!data || (data[0] == '-' && !data[1]) ? "(not set)" : data) : (var->gdata ? var->gdata : "(not set)"));
+
+      if (sdata)
+        free(sdata);
     }
     return 1;
   }