Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.304
diff -u -p -r1.304 filter.module
--- modules/filter/filter.module	1 Dec 2009 13:14:42 -0000	1.304
+++ modules/filter/filter.module	2 Dec 2009 13:07:38 -0000
@@ -770,9 +770,11 @@ function _filter_tips($format_id, $long 
     $filters = filter_list_format($format->format);
     $tips[$format->name] = array();
     foreach ($filters as $name => $filter) {
-      if ($filter->status && isset($filter_info[$name]['tips callback']) && function_exists($filter_info[$name]['tips callback'])) {
+      if (isset($filter_info[$name]['tips callback']) && function_exists($filter_info[$name]['tips callback'])) {
         $tip = $filter_info[$name]['tips callback']($filter, $format, $long);
-        $tips[$format->name][$name] = array('tip' => $tip, 'id' => $name);
+        if ($tip) {
+          $tips[$format->name][$name] = array('tip' => $tip, 'id' => $name);
+        }
       }
     }
   }
@@ -954,9 +956,29 @@ function _filter_html($text, $filter) {
 function _filter_html_tips($filter, $format, $long = FALSE) {
   global $base_url;
 
-  if (!($allowed_html = $filter->settings['allowed_html'])) {
-    return;
+  if (!$filter->status || !($allowed_html = $filter->settings['allowed_html'])) {
+    // If the text format does not remove or escape any HTML, add a special
+    // filter tip which explains that HTML is allowed. We detect these cases by
+    // defining an invalid HTML tag and running it through the text format.
+    // Since any (reasonable) HTML filter uses a white-list approach when
+    // filtering, we expect this tag to either be removed or escaped if the
+    // text format restricts HTML in any way.
+    // @todo This will fail with filters that add generic attributes, i.e.
+    //     '<abcdefghij about="foo" />'
+    //   or filters that change XHTML to HTML, i.e.
+    //     '<abcdefghij>'
+    //   so the proper way to check this would be to use PHP DOM functions.
+    $output = '';
+    $fake_tag = '<abcdefghij />';
+    if (strpos(check_markup($fake_tag, $format->format), $fake_tag) !== FALSE) {
+      $output = t('All HTML tags are allowed.');
+    }
+    if ($long) {
+      return '<p>' . $output . '</p>';
+    }
+    return $output;
   }
+
   $output = t('Allowed HTML tags: @tags', array('@tags' => $allowed_html));
   if (!$long) {
     return $output;
@@ -1126,6 +1148,9 @@ function _filter_url_trim($text, $length
  * Filter tips callback for URL filter.
  */
 function _filter_url_tips($filter, $format, $long = FALSE) {
+  if (!$filter->status) {
+    return;
+  }
   return t('Web page addresses and e-mail addresses turn into links automatically.');
 }
 
@@ -1199,6 +1224,9 @@ function _filter_autop($text) {
  * Filter tips callback for auto-paragraph filter.
  */
 function _filter_autop_tips($filter, $format, $long = FALSE) {
+  if (!$filter->status) {
+    return;
+  }
   if ($long) {
     return t('Lines and paragraphs are automatically recognized. The &lt;br /&gt; line break, &lt;p&gt; paragraph and &lt;/p&gt; close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.');
   }
@@ -1218,7 +1246,9 @@ function _filter_html_escape($text) {
  * Filter tips callback for HTML escaping filter.
  */
 function _filter_html_escape_tips($filter, $format, $long = FALSE) {
-  return t('No HTML tags allowed.');
+  if ($filter->status) {
+    return t('No HTML tags allowed.');
+  }
 }
 
 /**
