--- modules/comment/comment.module.orig	2009-08-17 13:50:14.000000000 +0300
+++ modules/comment/comment.module	2009-08-17 14:30:09.000000000 +0300
@@ -1237,6 +1237,9 @@ function comment_save($comment) {
 
   field_attach_presave('comment', $comment);
 
+  // Allow modules to alter the comment before saving.
+  module_invoke_all('comment_presave', $comment);
+
   if ($comment->cid) {
     // Update the comment in the database.
     db_update('comment')
--- modules/comment/comment.api.php.orig	2009-08-17 13:50:37.000000000 +0300
+++ modules/comment/comment.api.php	2009-08-17 14:34:43.000000000 +0300
@@ -12,6 +12,19 @@
  */
 
 /**
+ * The comment passed validation and is about to be saved.
+ *
+ * Modules may make changes to the comment before it is saved to the database.
+ *
+ * @param $comment
+ *   The comment object.
+ */
+function hook_comment_presave($comment) {
+  // Remove leading & trailing spaces from the comment subject.
+  $comment->subject = trim($comment->subject);
+}
+
+/**
  * The comment is being inserted.
  *
  * @param $comment
