Răsfoiți Sursa

* 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 17 ani în urmă
părinte
comite
6865e6e873
2 a modificat fișierele cu 14 adăugiri și 0 ștergeri
  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
 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)
 * 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.
 * 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);
       dprintf(idx, "Failed to modify %s list.\n", var->name);
       return 0;
       return 0;
     } else {
     } 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);
       var_set(var, botnick, data);
       if (botnick)
       if (botnick)
         var_set_userentry(botnick, name, data);
         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)"));
       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;
     return 1;
   }
   }