commit 858b560f50e755616c5be29c8014ccfda9429544
Author: James Gilliland <neclimdul@gmail.com>
Date:   Wed Oct 27 15:13:32 2010 -0500

    Backport drupal_hmac_base64 for simpletest

diff --git includes/bootstrap.inc includes/bootstrap.inc
index d0a6062..a6e9a78 100644
--- includes/bootstrap.inc
+++ includes/bootstrap.inc
@@ -1066,6 +1066,24 @@ function drupal_is_denied($type, $mask) {
 }
 
 /**
+ * Calculate a base-64 encoded, URL-safe sha-256 hmac.
+ *
+ * @param $data
+ *   String to be validated with the hmac.
+ * @param $key
+ *   A secret string key.
+ *
+ * @return
+ *   A base-64 encoded sha-256 hmac, with + replaced with -, / with _ and
+ *   any = padding characters removed.
+ */
+function drupal_hmac_base64($data, $key) {
+  $hmac = base64_encode(hash_hmac('sha256', $data, $key, TRUE));
+  // Modify the hmac so it's safe to use in URLs.
+  return strtr($hmac, array('+' => '-', '/' => '_', '=' => ''));
+}
+
+/**
  * Generates a default anonymous $user object.
  *
  * @return Object - the user object.
@@ -1362,7 +1380,7 @@ function drupal_valid_test_ua($user_agent) {
 //  $key = sha1(serialize($databases) . filectime($filepath) . fileinode($filepath), TRUE);
   $key = sha1(serialize($db_url) . filectime($filepath) . fileinode($filepath), TRUE);
   // The HMAC must match.
-  return $hmac == base64_encode(hash_hmac('sha1', $check_string, $key, TRUE));
+  return $hmac == drupal_hmac_base64($check_string, $key);
 }
 
 /**
@@ -1385,5 +1403,5 @@ function drupal_generate_test_ua($prefix) {
    // Generate a moderately secure HMAC based on the database credentials.
    $salt = uniqid('', TRUE);
    $check_string = $prefix . ';' . time() . ';' . $salt;
-   return  $check_string . ';' . base64_encode(hash_hmac('sha1', $check_string, $key, TRUE));
+   return  $check_string . ';' . drupal_hmac_base64($check_string, $key);
 }
diff --git includes/common.inc includes/common.inc
index f251f43..b5ed963 100644
--- includes/common.inc
+++ includes/common.inc
@@ -3953,7 +3953,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
         'line' => $error['%line'],
       ),
     );
-    header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));
+//    header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));
     $number++;
   }
 
@@ -3966,7 +3966,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
   }
 
   if ($fatal) {
-    drupal_set_header('500 Service unavailable (with message)');
+    drupal_set_header('Status: 500 Service unavailable (with message)');
   }
 
   if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
