From: Kevin Day Date: Wed, 26 Apr 2017 16:10:41 +0000 (-0500) Subject: Bugfix: http request uri and http response location fixes X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=66128b17337fdd14f9c657016fe51dda4402890f;p=koopa Bugfix: http request uri and http response location fixes The request uri should include the scheme and authority where possible. Fix a syntax error containing '$$' instead of '$'. The response location needs to fully support an array. --- diff --git a/common/base/classes/base_http.php b/common/base/classes/base_http.php index a510ef5..f868a74 100644 --- a/common/base/classes/base_http.php +++ b/common/base/classes/base_http.php @@ -2547,7 +2547,7 @@ class c_base_http extends c_base_rfc_string { $uri_string = $uri; } - $text = $this->pr_rfc_string_prepare($$uri_string); + $text = $this->pr_rfc_string_prepare($uri_string); if ($text['invalid']) { unset($text); @@ -4118,7 +4118,7 @@ class c_base_http extends c_base_rfc_string { return c_base_return_error::s_value(array(), 'c_base_return_array', $error); } - return c_base_return_string::s_new($this->response[self::RESPONSE_LOCATION]); + return c_base_return_array::s_new($this->response[self::RESPONSE_LOCATION]); } /** @@ -6486,7 +6486,21 @@ class c_base_http extends c_base_rfc_string { return; } - $text = $this->pr_rfc_string_prepare($this->headers['uri']); + // attempt to reconstruct the uri as a full url, if possible. + $uri = $this->headers['uri']; + + if (isset($_SERVER['SERVER_NAME']) && is_string($_SERVER['SERVER_NAME']) && mb_strlen($_SERVER['SERVER_NAME']) > 0) { + if (isset($_SERVER['HTTPS'])) { + $uri = 'https://' . $_SERVER['SERVER_NAME'] . $uri; + } + else { + $uri = 'http://' . $_SERVER['SERVER_NAME'] . $uri; + } + } + + $text = $this->pr_rfc_string_prepare($uri); + unset($uri); + if ($text['invalid']) { $this->request[self::REQUEST_URI]['invalid'] = TRUE; unset($text); diff --git a/program/reservation/reservation_redirects.php b/program/reservation/reservation_redirects.php index 00a366a..25c912e 100644 --- a/program/reservation/reservation_redirects.php +++ b/program/reservation/reservation_redirects.php @@ -53,7 +53,7 @@ final class c_reservation_path_redirect extends c_base_path { // @todo: store all errors on return. $errors = array(); - if (is_string($field_destination)) { + if (is_string($field_destination) || is_array($field_destination)) { $path->set_field_destination($field_destination); }