[Openvas-commits] r12225 - in trunk/gsa: . src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Nov 30 15:27:10 CET 2011


Author: mattm
Date: 2011-11-30 15:27:10 +0100 (Wed, 30 Nov 2011)
New Revision: 12225

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
Log:
	* src/gsad.c (init_validator): Allow space around numbers.
	(params_mhd_validate_values, params_mhd_validate): If the rule is "number"
	or an alias for "number", then strip any leading and trailing space from
	the number if it is valid.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-11-30 14:26:22 UTC (rev 12224)
+++ trunk/gsa/ChangeLog	2011-11-30 14:27:10 UTC (rev 12225)
@@ -1,5 +1,12 @@
 2011-11-30  Matthew Mundell <matthew.mundell at greenbone.net>
 
+	* src/gsad.c (init_validator): Allow space around numbers.
+	(params_mhd_validate_values, params_mhd_validate): If the rule is "number"
+	or an alias for "number", then strip any leading and trailing space from
+	the number if it is valid.
+
+2011-11-30  Matthew Mundell <matthew.mundell at greenbone.net>
+
 	In the validator, also store the rule name for aliases.
 
 	* src/validator.c (openvas_validator_rule_new)

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2011-11-30 14:26:22 UTC (rev 12224)
+++ trunk/gsa/src/gsad.c	2011-11-30 14:27:10 UTC (rev 12225)
@@ -678,7 +678,8 @@
   openvas_validator_add (validator, "name",       "^[-_[:alnum:], \\./]{1,80}$");
   openvas_validator_add (validator, "info_name",  "(?s)^.*$");
   openvas_validator_add (validator, "info_type",  "(?s)^.*$");
-  openvas_validator_add (validator, "number",     "^[0-9]+$");
+  /* Number is special cased in params_mhd_validate to remove the space. */
+  openvas_validator_add (validator, "number",     "^ *[0-9]+ *$");
   openvas_validator_add (validator, "observers",       "^[-_ [:alnum:]]*$");
   openvas_validator_add (validator, "optional_number", "^[0-9]*$");
   openvas_validator_add (validator, "oid",        "^[0-9.]{1,80}$");
@@ -1067,7 +1068,17 @@
                 param->valid = 0;
               }
             else
-              param->valid = 1;
+              {
+                const gchar *alias_for;
+
+                param->valid = 1;
+
+                alias_for = openvas_validator_alias_for (validator, name);
+                if ((param->value && (strcmp ((gchar*) name, "number") == 0))
+                    || (alias_for && (strcmp ((gchar*) alias_for, "number") == 0)))
+                  /* Remove any leading or trailing space from numbers. */
+                  param->value = g_strstrip (param->value);
+              }
             break;
           case 2:
           default:
@@ -1102,6 +1113,7 @@
     {
       param_t *param;
       param = (param_t*) value;
+
       if (openvas_validate (validator, name, param->value))
         {
           param->original_value = param->value;
@@ -1109,8 +1121,18 @@
           param->valid = 0;
         }
       else
-        param->valid = 1;
+        {
+          const gchar *alias_for;
 
+          param->valid = 1;
+
+          alias_for = openvas_validator_alias_for (validator, name);
+          if ((param->value && (strcmp ((gchar*) name, "number") == 0))
+              || (alias_for && (strcmp ((gchar*) alias_for, "number") == 0)))
+            /* Remove any leading or trailing space from numbers. */
+            param->value = g_strstrip (param->value);
+        }
+
       if (param->values)
         params_mhd_validate_values (name, param->values);
     }



More information about the Openvas-commits mailing list