diff --git a/image_caption/contrib/image_caption_filter.module b/image_caption/contrib/image_caption_filter.module
index 766ed2c..23dc141 100644
--- a/image_caption/contrib/image_caption_filter.module
+++ b/image_caption/contrib/image_caption_filter.module
@@ -26,7 +26,7 @@ function image_caption_filter_filter_info() {
       'classes' => variable_get('image_caption_filter_classes', 'image-left image-right standalone-image'),
     ),
   );
-
+
   return $filters;
 }

@@ -36,7 +36,7 @@ function image_caption_filter_filter_info() {
 function image_caption_filter_filter_filter_image_caption_settings($form, &$form_state, $filter, $format, $defaults, $filters) {
   $filter->settings += $defaults;
   $elements = array();
-
+
   $elements['classes'] = array(
     '#type' => 'textfield',
     '#title' => t('Classes to be searched for image captions'),
@@ -45,7 +45,7 @@ function image_caption_filter_filter_filter_image_caption_settings($form, &$form
     '#description' => t('Enter a space-separated list of classes. The filter will only operate on images which have one of these CSS classes and have a title attribute.'),
     '#required' => TRUE,
   );
-
+
   return $elements;
 }

@@ -71,15 +71,15 @@ function image_caption_filter_filter_filter_image_caption_tips($filter, $format,

 /**
  * Storage for active class names
- *
+ *
  * _image_caption_filter_do_img_titles() is called by preg_replace_callback() and this function allows only one argument.
  */
 function image_caption_filter_active_classes($classes = NULL) {
   static $_classes = array();
-  if ($classes != NULL) {
-    $_classes = $classes;
+  if ($classes != NULL) {
+    $_classes = $classes;
   }
-
+
   return $_classes;
 }

@@ -105,7 +105,7 @@ function _image_caption_filter_do_img_titles($img_tag_matches, $active_classes =

     if (count(array_intersect($classes, $active_classes)) > 0) {
       // only execute this filter on img tags that have a title attribute
-      $has_title = preg_match('/title=\"(.+?)\"/i', $img_tag, $matches) > 0;
+      $has_title = preg_match('/title="([^"]+)"/i', $img_tag, $matches) > 0;
       if ($has_title) {
         $title = $matches[1];

@@ -157,15 +157,15 @@ function _image_caption_filter_do_img_titles($img_tag_matches, $active_classes =
         if (!empty($width)) {
           $element['image_caption']['#attributes']['style'][] = 'width:' . $width . 'px;';
         }
-
+
         if (!empty($float)) {
           $element['image_caption']['#attributes']['style'][] = 'float:' . $float;
         }
-
+
         $return_text = render($element);
       }
     }
   }
-
+
   return $return_text;
 }
