Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v
retrieving revision 1.1.2.39
diff -u -p -r1.1.2.39 mollom.admin.inc
--- mollom.admin.inc	15 Sep 2010 02:56:56 -0000	1.1.2.39
+++ mollom.admin.inc	18 Sep 2010 17:14:20 -0000
@@ -387,13 +387,33 @@ function mollom_admin_blacklist_form(&$f
  * Form submit handler to save a text string to the Mollom blacklist.
  */
 function mollom_admin_blacklist_form_submit($form, &$form_state) {
-  $result = mollom('mollom.addBlacklistText', $form_state['values']['entry']);
-
+  $data = array(
+    'text' => trim($form_state['values']['entry']['text'], ' '),
+    'context' => $form_state['values']['entry']['context'],
+    'reason' => $form_state['values']['entry']['reason'],
+  );
+  $result = mollom('mollom.addBlacklistText', $data);
+
+  $args = array(
+    '@text' => $data['text'],
+    '@context' => $data['context'],
+    '@reason' => $data['reason'],
+  );
   if ($result === TRUE) {
     drupal_set_message(t('The entry was added to the blacklist.'));
+    _mollom_watchdog(array(
+      'Added @text (@context) to @reason blacklist.' => $args,
+      'Data:<pre>@data</pre>' => array('@data' => $data),
+      'Result:<pre>@result</pre>' => array('@result' => $result),
+    ));
   }
   else {
     drupal_set_message(t('An error occurred upon trying to add the text to the blacklist.'), 'error');
+    _mollom_watchdog(array(
+      'Failed to add @text (%context) to @reason blacklist.' => $args,
+      'Data:<pre>@data</pre>' => array('@data' => $data),
+      'Result:<pre>@result</pre>' => array('@result' => $result),
+    ), WATCHDOG_ERROR);
   }
 }
 
@@ -477,11 +497,26 @@ function mollom_admin_blacklist_delete_s
   );
   $result = mollom('mollom.removeBlacklistText', $data);
 
+  $args = array(
+    '@text' => $data['text'],
+    '@context' => $data['context'],
+    '@reason' => $data['reason'],
+  );
   if ($result === TRUE) {
     drupal_set_message(t('The entry was removed from the blacklist.'));
+    _mollom_watchdog(array(
+      'Removed @text (@context) from @reason blacklist.' => $args,
+      'Data:<pre>@data</pre>' => array('@data' => $data),
+      'Result:<pre>@result</pre>' => array('@result' => $result),
+    ));
   }
   else {
     drupal_set_message(t('An error occurred upon trying to remove the item from the blacklist.'), 'error');
+    _mollom_watchdog(array(
+      'Failed to removed @text (%context) from @reason blacklist.' => $args,
+      'Data:<pre>@data</pre>' => array('@data' => $data),
+      'Result:<pre>@result</pre>' => array('@result' => $result),
+    ), WATCHDOG_ERROR);
   }
 
   $form_state['redirect'] = 'admin/settings/mollom/blacklist';
Index: tests/mollom.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom.test,v
retrieving revision 1.1.2.60
diff -u -p -r1.1.2.60 mollom.test
--- tests/mollom.test	15 Sep 2010 02:56:56 -0000	1.1.2.60
+++ tests/mollom.test	18 Sep 2010 17:34:00 -0000
@@ -1347,7 +1347,11 @@ class MollomBlacklistTestCase extends Mo
     $blacklist = mollom('mollom.listBlacklistText');
     foreach ($blacklist as $entry) {
       if (strtotime($entry['created']) - time() > 86400) {
-        mollom('mollom.removeBlacklistText', array('text' => $entry['text']));
+        mollom('mollom.removeBlacklistText', array(
+          'text' => $entry['text'],
+          'context' => $entry['context'],
+          'reason' => $entry['reason'],
+        ));
       }
     }
 
@@ -1356,8 +1360,9 @@ class MollomBlacklistTestCase extends Mo
     $term = drupal_strtolower(preg_replace('/[^a-zA-Z]/', '', $this->randomName()));
     $result = mollom('mollom.addBlacklistText', array(
       'text' => $term,
-      'match' => 'contains',
+      'context' => 'everything',
       'reason' => 'spam',
+      'match' => 'contains',
     ));
     $this->assertIdentical($result, TRUE, t('The text was blacklisted.'));
 
@@ -1377,12 +1382,12 @@ class MollomBlacklistTestCase extends Mo
     ));
     $this->assertEqual($result['spam'], MOLLOM_ANALYSIS_SPAM, t('Partial match was blocked.'));
 
-    // To update the work (i.e. to change the 'match' property), we simply
-    // overwrite it.
+    // Update the blacklist entry to match the term only exactly.
     $result = mollom('mollom.addBlacklistText', array(
       'text' => $term,
-      'match' => 'exact',
+      'context' => 'everything',
       'reason' => 'spam',
+      'match' => 'exact',
     ));
     $this->assertTrue($result, t('The text was blacklisted.'));
 
@@ -1396,8 +1401,20 @@ class MollomBlacklistTestCase extends Mo
     ));
     $this->assertNotEqual($result['spam'], MOLLOM_ANALYSIS_SPAM, t('Partial match was not blocked.'));
 
-    $result = mollom('mollom.removeBlacklistText', array('text' => $term));
+    $result = mollom('mollom.removeBlacklistText', array(
+      'text' => $term,
+      'context' => 'everything',
+      'reason' => 'spam',
+    ));
     $this->assertTrue($result, t('The blacklisted text was removed.'));
+
+    // Try to remove a non-existing entry.
+    $result = mollom('mollom.removeBlacklistText', array(
+      'text' => $term,
+      'context' => 'everything',
+      'reason' => 'spam',
+    ));
+    $this->assertNotIdentical($result, TRUE, t('Error response for a non-existing blacklist text found.'));
   }
 
   /**
@@ -1415,8 +1432,8 @@ class MollomBlacklistTestCase extends Mo
     $this->drupalGet('admin/settings/mollom/blacklist');
     $text = $this->randomName();
     $edit = array(
-      'entry[context]' => 'everything',
       'entry[text]' => $text,
+      'entry[context]' => 'everything',
     );
     $this->drupalPost(NULL, $edit, t('Add'));
     $this->assertText(t('The entry was added to the blacklist.'));
@@ -1434,8 +1451,8 @@ class MollomBlacklistTestCase extends Mo
     $this->drupalGet('admin/settings/mollom/blacklist/profanity');
     $text = $this->randomName();
     $edit = array(
-      'entry[context]' => 'everything',
       'entry[text]' => $text,
+      'entry[context]' => 'everything',
     );
     $this->drupalPost(NULL, $edit, t('Add'));
     $this->assertText(t('The entry was added to the blacklist.'));
