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 23:31:46 -0000
@@ -1117,14 +1117,31 @@ function drupal_unpack($obj, $field = 'd
   return $obj;
 }
 
-/**
- * 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.
- */
-function check_plain($text) {
-  return drupal_validate_utf8($text) ? htmlspecialchars($text, ENT_QUOTES) : '';
+if (version_compare(PHP_VERSION, '5.2.5', '>=')) {
+  /**
+   * Encode special characters in a plain-text string for display as HTML.
+   *
+   * 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 htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
+  }
+}
+else {
+  function check_plain($text) {
+    return (preg_match('/^./us', $text) == 1) ? htmlspecialchars($text, ENT_QUOTES, 'UTF-8') : '';
+  }
 }
 
 /**
