request.php: add type check to the not empty check of a string
The not equal comparison (<>) of a variable with an empty string could lead to false positive results as the compare do not check the type and thereby could not make sure that the checked variable is a string. The usage of the not identical comparison operator (!==) make sure that the variable is a string and not empty.
This commit is contained in:
parent
d4f98923b9
commit
ecb9d37b55
|
@ -14,7 +14,7 @@ class OC_Request {
|
||||||
private static function isOverwriteCondition($type = '') {
|
private static function isOverwriteCondition($type = '') {
|
||||||
$regex = '/' . OC_Config::getValue('overwritecondaddr', '') . '/';
|
$regex = '/' . OC_Config::getValue('overwritecondaddr', '') . '/';
|
||||||
return $regex === '//' or preg_match($regex, $_SERVER['REMOTE_ADDR']) === 1
|
return $regex === '//' or preg_match($regex, $_SERVER['REMOTE_ADDR']) === 1
|
||||||
or ($type <> 'protocol' and OC_Config::getValue('forcessl', false));
|
or ($type !== 'protocol' and OC_Config::getValue('forcessl', false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,7 @@ class OC_Request {
|
||||||
if(OC::$CLI) {
|
if(OC::$CLI) {
|
||||||
return 'localhost';
|
return 'localhost';
|
||||||
}
|
}
|
||||||
if(OC_Config::getValue('overwritehost', '')<>'' and self::isOverwriteCondition()) {
|
if(OC_Config::getValue('overwritehost', '') !== '' and self::isOverwriteCondition()) {
|
||||||
return OC_Config::getValue('overwritehost');
|
return OC_Config::getValue('overwritehost');
|
||||||
}
|
}
|
||||||
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
|
||||||
|
@ -53,7 +53,7 @@ class OC_Request {
|
||||||
* Returns the server protocol. It respects reverse proxy servers and load balancers
|
* Returns the server protocol. It respects reverse proxy servers and load balancers
|
||||||
*/
|
*/
|
||||||
public static function serverProtocol() {
|
public static function serverProtocol() {
|
||||||
if(OC_Config::getValue('overwriteprotocol', '')<>'' and self::isOverwriteCondition('protocol')) {
|
if(OC_Config::getValue('overwriteprotocol', '') !== '' and self::isOverwriteCondition('protocol')) {
|
||||||
return OC_Config::getValue('overwriteprotocol');
|
return OC_Config::getValue('overwriteprotocol');
|
||||||
}
|
}
|
||||||
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
|
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
|
||||||
|
@ -77,7 +77,7 @@ class OC_Request {
|
||||||
*/
|
*/
|
||||||
public static function requestUri() {
|
public static function requestUri() {
|
||||||
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
|
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
|
||||||
if (OC_Config::getValue('overwritewebroot', '') <> '' and self::isOverwriteCondition()) {
|
if (OC_Config::getValue('overwritewebroot', '') !== '' and self::isOverwriteCondition()) {
|
||||||
$uri = self::scriptName() . substr($uri, strlen($_SERVER['SCRIPT_NAME']));
|
$uri = self::scriptName() . substr($uri, strlen($_SERVER['SCRIPT_NAME']));
|
||||||
}
|
}
|
||||||
return $uri;
|
return $uri;
|
||||||
|
@ -92,7 +92,7 @@ class OC_Request {
|
||||||
*/
|
*/
|
||||||
public static function scriptName() {
|
public static function scriptName() {
|
||||||
$name = $_SERVER['SCRIPT_NAME'];
|
$name = $_SERVER['SCRIPT_NAME'];
|
||||||
if (OC_Config::getValue('overwritewebroot', '') <> '' and self::isOverwriteCondition()) {
|
if (OC_Config::getValue('overwritewebroot', '') !== '' and self::isOverwriteCondition()) {
|
||||||
$serverroot = str_replace("\\", '/', substr(__DIR__, 0, -4));
|
$serverroot = str_replace("\\", '/', substr(__DIR__, 0, -4));
|
||||||
$suburi = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen($serverroot)));
|
$suburi = str_replace("\\", "/", substr(realpath($_SERVER["SCRIPT_FILENAME"]), strlen($serverroot)));
|
||||||
$name = OC_Config::getValue('overwritewebroot', '') . $suburi;
|
$name = OC_Config::getValue('overwritewebroot', '') . $suburi;
|
||||||
|
|
Loading…
Reference in New Issue