Index: modules/contact.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact.module,v
retrieving revision 1.40
diff -u -p -r1.40 contact.module
--- modules/contact.module	14 Jan 2006 10:33:22 -0000	1.40
+++ modules/contact.module	18 Jan 2006 03:04:42 -0000
@@ -177,8 +177,14 @@ function contact_mail_user_submit($form_
   $to = $account->mail;
   $from = $user->mail;
 
+  // Detect and prevent email injection exploit and notify administrator about attempt
+  $safe_subject = str_replace(array("\r", "\n"), '', $edit['subject']);
+  if ($safe_subject != $edit['subject']) {
+    watchdog('mail', 'Email injection exploit attempted in contact form subject: ' . check_plain($edit['subject']), WATCHDOG_NOTICE);
+  }
+
   // Format the subject:
-  $subject = '['. variable_get('site_name', 'drupal') .'] '. $edit['subject'];
+  $subject = '['. variable_get('site_name', 'drupal') .'] '. $safe_subject;
 
   // Prepare the body:
   $body = implode("\n\n", $message);
