? number-1026878.patch
Index: modules/field/modules/number/number.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/number/number.module,v
retrieving revision 1.46
diff -u -p -r1.46 number.module
--- modules/field/modules/number/number.module	31 Oct 2010 12:11:59 -0000	1.46
+++ modules/field/modules/number/number.module	14 Jan 2011 16:07:09 -0000
@@ -379,10 +379,20 @@ function number_field_widget_validate($e
     if ($value != preg_replace($regexp, '', $value)) {
       form_error($element, $message);
     }
+    
     else {
-      // Substitute the decimal separator,
+      
       if ($type == 'decimal' || $type == 'float') {
-        $value = strtr($value, $field['settings']['decimal_separator'], '.');
+        // Check to make sure the decimal separator isn't in the field more than once
+        if (substr_count($value, $field['settings']['decimal_separator']) > 1) {
+          $message = t('There should only be one decimal separator (@separator) in %field.',
+            array('@separator' => $field['settings']['decimal_separator'], '%field' => t($instance['label'])));
+          form_error($element, $message);
+        }
+        else {
+          // Substitute the decimal separator; things should be fine.
+          $value = strtr($value, $field['settings']['decimal_separator'], '.');          
+        }
       }
       form_set_value($element, $value, $form_state);
     }
Index: modules/field/modules/number/number.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/number/number.test,v
retrieving revision 1.1
diff -u -p -r1.1 number.test
--- modules/field/modules/number/number.test	23 Oct 2010 21:03:22 -0000	1.1
+++ modules/field/modules/number/number.test	14 Jan 2011 16:07:09 -0000
@@ -71,5 +71,32 @@ class NumberFieldTestCase extends Drupal
     $id = $match[1];
     $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created'));
     $this->assertRaw(round($value, 2), t('Value is displayed.'));
+    
+    $this->tryCreateContentWithInvalidDecimalAndAssertFail();
+  }
+  
+  function tryCreateContentWithInvalidDecimalAndAssertFail() {
+    $bad_entries = array(
+      '3.14.159',
+      '0..45469',
+      '..4589',
+      '6.459.52',
+      '6.3..25',   
+    );
+    $langcode = LANGUAGE_NONE;
+
+    foreach ($bad_entries as $bad_entry) {
+      $this->drupalGet('test-entity/add/test-bundle');
+      $edit = array(
+        "{$this->field['field_name']}[$langcode][0][value]" => $bad_entry,
+      );
+      $this->drupalPost(NULL, $edit, t('Save'));
+      $this->assertText(
+        t('There should only be one decimal separator (@separator)', 
+          array('@separator' => $this->field['settings']['decimal_separator'])),
+        t('Correctly failed to save decimal value with more than one decimal point.')
+      );
+    }
   }
 }
+
