Skip to content

Commit b8310f2

Browse files
author
dries
committed
- Patch #482646 by Dave Reid et al: check for existence of ['HTTP_USER_AGENT'] for the SimpleTest user agent.
1 parent d2012fb commit b8310f2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

includes/common.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
// $Id: common.inc,v 1.928 2009-07-03 19:21:54 dries Exp $
2+
// $Id: common.inc,v 1.929 2009-07-04 14:49:31 dries Exp $
33

44
/**
55
* @file
@@ -552,7 +552,7 @@ function drupal_http_request($url, array $options = array()) {
552552
// user-agent is used to ensure that multiple testing sessions running at the
553553
// same time won't interfere with each other as they would if the database
554554
// prefix were stored statically in a file or database variable.
555-
if (preg_match("/simpletest\d+/", $db_prefix, $matches)) {
555+
if (is_string($db_prefix) && preg_match("/^simpletest\d+/", $db_prefix, $matches)) {
556556
$options['headers']['User-Agent'] = $matches[0];
557557
}
558558

@@ -809,7 +809,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
809809

810810
// When running inside the testing framework, we relay the errors
811811
// to the tested site by the way of HTTP headers.
812-
if (preg_match("/^simpletest\d+/", $_SERVER['HTTP_USER_AGENT']) && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
812+
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/^simpletest\d+$/", $_SERVER['HTTP_USER_AGENT']) && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
813813
// $number does not use drupal_static as it should not be reset
814814
// as it uniquely identifies each PHP error.
815815
static $number = 0;

install.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
// $Id: install.php,v 1.181 2009-06-30 21:44:06 dries Exp $
2+
// $Id: install.php,v 1.182 2009-07-04 14:49:31 dries Exp $
33

44
/**
55
* Root directory of Drupal installation.
@@ -28,7 +28,7 @@ function install_main() {
2828
// The user agent header is used to pass a database prefix in the request when
2929
// running tests. However, for security reasons, it is imperative that no
3030
// installation be permitted using such a prefix.
31-
if (preg_match("/^simpletest\d+$/", $_SERVER['HTTP_USER_AGENT'])) {
31+
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/^simpletest\d+$/", $_SERVER['HTTP_USER_AGENT'])) {
3232
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
3333
exit;
3434
}

0 commit comments

Comments
 (0)