Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.302
diff -u -p -r1.302 bootstrap.inc
--- includes/bootstrap.inc	24 Aug 2009 00:14:18 -0000	1.302
+++ includes/bootstrap.inc	24 Aug 2009 17:01:32 -0000
@@ -1120,11 +1120,26 @@ function drupal_unpack($obj, $field = 'd
 /**
  * Encode special characters in a plain-text string for display as HTML.
  *
- * Uses drupal_validate_utf8 to prevent cross site scripting attacks on
- * Internet Explorer 6.
+ * Uses drupal_validate_utf8() for PHP versions < 5.2.5 to prevent cross site
+ * scripting attacks on Internet Explorer 6.
+ *
+ * @see drupal_validate_utf8()
+ * @see http://www.php.net/releases/5_2_5.php
+ *
+ * @param $text
+ *   The text to be checked or processed.
+ *
+ * @return
+ *   An HTML safe version of $text, or an empty string if $text is not
+ *   valid UTF-8.
  */
 function check_plain($text) {
-  return drupal_validate_utf8($text) ? htmlspecialchars($text, ENT_QUOTES) : '';
+  static $new_php;
+
+  if (!isset($new_php)) {
+    $new_php = version_compare(PHP_VERSION, '5.2.5', '>=');
+  }
+  return ($new_php || drupal_validate_utf8($text) ? htmlspecialchars($text, ENT_QUOTES, 'UTF-8') : '');
 }
 
 /**
