[bugs] [Bug 1066] New - [sam] spamassassin.php numeric format

bugs@bugs.horde.org bugs@bugs.horde.org
Mon, 7 Oct 2002 15:41:02 -0300


http://bugs.horde.org/show_bug.cgi?id=1066

*** shadow/1066	Mon Oct  7 15:41:02 2002
--- shadow/1066.tmp.27813	Mon Oct  7 15:41:02 2002
***************
*** 0 ****
--- 1,49 ----
+ Bug#: 1066
+ Product: Horde
+ Version: 2.3 Unstable
+ Platform: PHP Code
+ OS/Version: All
+ Status: NEW   
+ Resolution: 
+ Severity: minor
+ Priority: P3
+ Component: Core
+ Area: BUILD
+ AssignedTo: chuck@horde.org                            
+ ReportedBy: horde@jonuschat.de               
+ URL: 
+ Summary: [sam] spamassassin.php numeric format
+ 
+ Checking of the numberformat for required_hits results in invalid numbers for 
+ spamassassin if the locale uses something other than the "." as the decimal 
+ separator.
+ 
+ The following patch switches to the C-locale before the check and reverts to 
+ the original locale afterwards:
+ 
+ --- spamassassin.php.orig       Mon Oct  7 20:21:16 2002
+ +++ spamassassin.php    Mon Oct  7 20:29:39 2002
+ @@ -24,6 +24,10 @@
+  /* Test if there was a submission of Form contents. */
+  if (Horde::getFormData('submitted')) {
+      /* Store the 'required_hits' spam option. */
+ +    /* Switch to default locale so SA doesn't choke on localized 
+ numberformats */
+ +    $origlocale = setlocale (LC_ALL, 0);
+ +    setlocale(LC_ALL, 'C');
+ +
+      if (is_numeric(Horde::getFormData('required_hits'))) {
+          /* Valid numeric data for 'required_hits' field. */
+          $sam->setOption('required_hits', Horde::getFormData('required_hits'));
+ @@ -31,6 +35,9 @@
+          /* Not valid numeric data for 'required_hits' field. */
+          $notification->push(_("Non-numeric value for Required 
+ Hits"), 'horde.error');
+      }
+ +
+ +    /* Switch back to userdefined locale */
+ +    setlocale(LC_ALL, $origlocale);
+ 
+      /* Store the 'subject_tag' spam option. */
+      $sam->setOption('subject_tag', Horde::getFormData('subject_tag'));
+