diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 5c2b8c9..59008f2 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -1566,6 +1566,7 @@ function _filter_url_parse_full_links($match) {
   $match[$i] = decode_entities($match[$i]);
   $caption = check_plain(_filter_url_trim($match[$i]));
   $match[$i] = check_plain($match[$i]);
+  $match[$i] = strip_tags($match[$i]);
   return '<a href="' . $match[$i] . '">' . $caption . '</a>' . $match[$i + 1];
 }
 
@@ -1735,7 +1736,7 @@ function _filter_autop($text) {
       $chunk = preg_replace('|<p>\s*</p>\n?|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace
       $chunk = preg_replace('!<p>\s*(</?' . $block . '[^>]*>)!', "$1", $chunk);
       $chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*</p>!', "$1", $chunk);
-      $chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks
+      $chunk = _make_line_breaks($chunk); // make line breaks
       $chunk = preg_replace('!(</?' . $block . '[^>]*>)\s*<br />!', "$1", $chunk);
       $chunk = preg_replace('!<br />(\s*</?(?:p|li|div|th|pre|td|ul|ol)>)!', '$1', $chunk);
       $chunk = preg_replace('/&([^#])(?![A-Za-z0-9]{1,8};)/', '&amp;$1', $chunk);
@@ -1746,6 +1747,43 @@ function _filter_autop($text) {
 }
 
 /**
+ * Checks to make sure \n is not in an attribute value.
+ */
+function _make_line_breaks($text) {
+  $parts = preg_split('/([^"]*)(")([^"]*)(")/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
+  $quote_count = 0;
+  $number_of_parts = count($parts);
+  if ($number_of_parts > 2) {
+    foreach ($parts as $index => $part) {
+      if (isset($part[0]) && ($part[0]=='"')) {
+        $quote_count++;
+        if ($quote_count % 2) { // just opened a quote
+          // make line breaks in part behind
+          $parts[$index-1]
+            = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $parts[$index-1]);
+        }
+        else {
+          if (strpos($parts[$index-3], '=') == FALSE) {
+            $parts[$index-1]
+              = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $parts[$index]);
+          }
+        }
+      }
+      elseif ($index == $number_of_parts-1) { // last part
+        // make line breaks
+        $parts[$index] = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $parts[$index]);
+      }
+    }
+    $output = implode($parts);
+  }
+  else { // no quotes in text
+    // make line breaks
+    $output = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $text);
+  }
+  return $output;
+}
+
+/**
  * Implements callback_filter_tips().
  *
  * Provides help for the auto-paragraph filter.
