Index: .htaccess
===================================================================
RCS file: /cvs/drupal/drupal/.htaccess,v
retrieving revision 1.56
diff -u -r1.56 .htaccess
--- .htaccess	18 Dec 2003 18:53:11 -0000	1.56
+++ .htaccess	6 Jan 2004 18:51:26 -0000
@@ -9,8 +9,7 @@
 </Files>
 
 # Set some options
-Options -Indexes
-Options FollowSymLinks
+Options -Indexes +FollowSymLinks
 
 # Customized server error messages:
 ErrorDocument 404 /index.php
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.302
diff -u -r1.302 common.inc
--- includes/common.inc	6 Jan 2004 12:09:41 -0000	1.302
+++ includes/common.inc	6 Jan 2004 18:51:30 -0000
@@ -684,8 +684,39 @@
   return form_select($title, $name, $value, $weights, $description, $extra);
 }
 
+/**
+ * Return a short help text about allowed markup. Can contain links to more 
+ * verbose explanations. To be put below submission form.
+ * 
+ * @todo
+ *   Integrate with <a href="http://drupal.org/book/view/1516">module_compose_tips()</a>.
+ */
 function form_allowed_tags_text() {
-  return variable_get("allowed_html", "") ? (t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))) : "";
+  static $allowed_tags;
+
+  if (!isset($allowed_tags)) {
+    // note: all hrefs in $msg_ have a high tabindex to not break direct tabbing between textarea and following fields
+    $msg_html_allowed = t('You can use (<a href="http://www.w3.org/TR/xhtml1/#diffs" tabindex="1000">X</a>)<a href="http://www.w3.org/TR/html401/" tabindex="1001">HTML</a>.');
+    $msg_nl2br = t('Newlines will be automatically converted to <a href="http://php.net/nl2br" tabindex="1002">&lt;br /&gt;</a>s if your post doesn\'t contain HTML or <a href="http://www.htmlhelp.com/reference/html40/inline.html" tabindex="1003">Inline Elements</a> only. Otherwise, you have to insert &lt;br /&gt;s and &lt;p&gt;s on your own.');
+    $msg_allowed_tags = t('Allowed tags: %htmlspecialchars.', array ('%htmlspecialchars' => drupal_specialchars(variable_get('allowed_html', ''))));
+    $msg_escape_special_characters = t('Make sure to <a href="http://www.w3.org/TR/html401/charset.html#h-5.3.2" tabindex="1004">escape special characters</a> (\'&lt;\' &raquo; \'&amp;lt;\', \'&gt;\' &raquo; \'&amp;gt;\', \'&amp;\' &raquo; \'&amp;amp;\').');
+    switch (variable_get('filter_html', FILTER_HTML_OFF)) {
+      case FILTER_HTML_OFF:
+        $allowed_tags = "$msg_html_allowed $msg_nl2br $msg_escape_special_characters";
+        break;
+      case FILTER_HTML_STRIP:
+        $allowed_tags = "$msg_html_allowed $msg_allowed_tags "
+          . (variable_get('filter_style', FILTER_STYLE_REMOVE) == FILTER_STYLE_REMOVE ? t("'style' attributes will be removed.") : '')
+          ." $msg_nl2br $msg_escape_special_characters";
+        break;
+      case FILTER_HTML_ESCAPE:
+        $allowed_tags = t('HTML will be escaped.');
+        break;
+    }
+    // TODO: add _compose_tips text / links.
+  }
+
+  return $allowed_tags;
 }
 
 /**
Index: modules/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter.module,v
retrieving revision 1.1
diff -u -r1.1 filter.module
--- modules/filter.module	5 Jan 2004 19:19:05 -0000	1.1
+++ modules/filter.module	6 Jan 2004 18:51:34 -0000
@@ -1,6 +1,39 @@
 <?php
 // $Id: filter.module,v 1.1 2004/01/05 19:19:05 unconed Exp $
 
+/**
+ * @defgroup filter Filter system
+ * @{
+ */
+
+/**
+ * @name filter_html
+ * @{
+ */
+/** do not filter HTML (default) */
+define('FILTER_HTML_OFF', 0);
+/** strip tags not in variable_get("allowed_html") */
+define('FILTER_HTML_STRIP', 1);
+/** escape all HTML */
+define('FILTER_HTML_ESCAPE', 2);
+// @}
+/**
+ * @name filter_style
+ * @{
+ */
+/** keep 'style' attributes if FILTER_HTML_STRIP */
+define('FILTER_STYLE_ALLOW', 0);
+/** remove 'style' attributes if FILTER_HTML_STRIP (default) */
+define('FILTER_STYLE_REMOVE', 1);
+// @}
+/**
+ * @name allowed_html
+ * @{
+ */
+define('FILTER_DEFAULT_ALLOWED_HTML', '<a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul>');
+// @}
+
+
 function filter_help($section = "admin/help#filter") {
   switch ($section) {
     case 'admin/system/modules#description':
@@ -30,9 +63,9 @@
 }
 
 function filter_conf_filters() {
-  $group1 .= form_radios(t("Filter HTML tags"), "filter_html", variable_get("filter_html", 0), array(0 => t("Do not filter"), 1 => t("Strip tags"), 2 => t("Escape tags")), t("How to deal with HTML and PHP tags in user-contributed content. If set to \"Strip tags\", dangerous tags are removed (see below).  If set to \"Escape tags\", all HTML is escaped and presented as it was typed."));
-  $group1 .= form_textfield(t("Allowed HTML tags"), "allowed_html", variable_get("allowed_html", "<a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul>"), 64, 255, t("If \"Strip tags\" is selected, optionally specify tags which should not be stripped.  'ON*' attributes and unclosed tags are always stripped."));
-  $group1 .= form_radios(t("HTML style attributes"), "filter_style", variable_get("filter_style", 1), array(t("Allowed"), t("Removed")), t("If \"Strip tags\" is selected, you can choose whether 'STYLE' attributes are allowed or removed from input."));
+  $group1 .= form_radios(t("Filter HTML tags"), "filter_html", variable_get("filter_html", FILTER_HTML_OFF), array(FILTER_HTML_OFF => t("Do not filter"), FILTER_HTML_STRIP => t("Strip tags"), FILTER_HTML_ESCAPE => t("Escape tags")), t("How to deal with HTML and PHP tags in user-contributed content. If set to \"Strip tags\", dangerous tags are removed (see below).  If set to \"Escape tags\", all HTML is escaped and presented as it was typed."));
+  $group1 .= form_textfield(t("Allowed HTML tags"), "allowed_html", variable_get("allowed_html", FILTER_DEFAULT_ALLOWED_HTML), 64, 255, t("If \"Strip tags\" is selected, optionally specify tags which should not be stripped.  'ON*' attributes and unclosed tags are always stripped."));
+  $group1 .= form_radios(t("HTML style attributes"), "filter_style", variable_get("filter_style", FILTER_STYLE_REMOVE), array(FILTER_STYLE_ALLOW => t("Allowed"), FILTER_STYLE_REMOVE => t("Removed")), t("If \"Strip tags\" is selected, you can choose whether 'STYLE' attributes are allowed or removed from input."));
   $output .= form_group(t("HTML filtering"), $group1);
 
   $group2 .= form_radios(t("Rewrite old URLs"), "rewrite_old_urls", variable_get("rewrite_old_urls", 0), array(t("Disabled"), t("Enabled")), t("The introduction of 'clean URLs' in Drupal 4.2.0 breaks internal URLs that date back from Drupal 4.1.0 and before.  If enabled, this filter will attempt to rewrite the old style URLs to avoid broken links.  If <code>mod_rewrite</code> is available on your system, use the rewrite rules in Drupal's <code>.htaccess</code> file instead as these will also correct external referrers."));
@@ -71,10 +104,10 @@
 }
 
 function filter_default($text) {
-  if (variable_get("filter_html", 0) == 1) {
+  if (variable_get("filter_html", FILTER_HTML_OFF) == FILTER_HTML_STRIP) {
     // Allow users to enter HTML, but filter it
     $text = strip_tags($text, variable_get("allowed_html", ""));
-    if (variable_get("filter_style", 1)) {
+    if (variable_get("filter_style", FILTER_STYLE_REMOVE)) {
       $text = preg_replace("/\Wstyle\s*=[^>]+?>/i", ">", $text);
     }
     $text = preg_replace("/\Won[a-z]+\s*=[^>]+?>/i", ">", $text);
@@ -84,27 +117,32 @@
     $text = filter_old_urls($text);
   }
 
-  if (variable_get("filter_html", 0) == 2) {
+  if (variable_get("filter_html", FILTER_HTML_OFF) == FILTER_HTML_ESCAPE) {
     // Escape HTML    
-    $text = htmlspecialchars($text);
+    $text = drupal_specialchars($text);
   }
 
   return trim($text);
 }
 
+/**
+ * This is a *temporary* filter to rewrite old-style URLs to new-style
+ * URLs (clean URLs).  Currently, URLs are being rewritten dynamically
+ * (ie. "on output"), however when these rewrite rules have been tested
+ * enough, we will use them to permanently rewrite the links in node
+ * and comment bodies.
+ * 
+ * @param $text
+ *   text to be filtered
+ * 
+ * @return
+ *   filtered text
+ */
 function filter_old_urls($text) {
   global $base_url;
 
   $end = substr($base_url, 12);
 
-  /*
-  ** This is a *temporary* filter to rewrite old-style URLs to new-style
-  ** URLs (clean URLs).  Currently, URLs are being rewritten dynamically
-  ** (ie. "on output"), however when these rewrite rules have been tested
-  ** enough, we will use them to permanently rewrite the links in node
-  ** and comment bodies.
-  */
-
   if (variable_get("clean_url", "0") == "0") {
     /*
     ** Relative URLs:
@@ -159,4 +197,6 @@
   return $text;
 }
 
+/** @} */ // END @defgroup filter Filter system
+
 ?>
\ No newline at end of file
