From 3f9de5b1d4000a45a7a5bc8ae9a74565ca3046e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sat, 9 Sep 2017 17:09:51 +0200 Subject: [PATCH 1/3] [ticket/15172] Use symfony request component to get port PHPBB3-15172 --- phpBB/includes/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6a36210dca..5178c1636b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1644,7 +1644,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false, */ function generate_board_url($without_script_path = false) { - global $config, $user, $request; + global $config, $user, $request, $symfony_request; $server_name = $user->host; @@ -1661,7 +1661,8 @@ function generate_board_url($without_script_path = false) } else { - $server_port = $request->server('SERVER_PORT', 0); + $server_port = $symfony_request->getPort(); + $forwarded_proto = $request->server('HTTP_X_FORWARDED_PROTO'); if (!empty($forwarded_proto) && $forwarded_proto === 'https') From f6b8f69e7ec51841785bc598a5e0533d946c1def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 10 Sep 2017 11:19:40 +0200 Subject: [PATCH 2/3] [ticket/15172] Add symfony_request to some tests PHPBB3-15172 --- tests/bbcode/parser_test.php | 3 ++- tests/bbcode/url_bbcode_test.php | 3 ++- tests/functions/make_clickable_email_test.php | 5 +++-- tests/functions/make_clickable_test.php | 3 ++- tests/text_formatter/s9e/factory_test.php | 6 ++++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index 4e85737c4f..b569d371f1 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -249,9 +249,10 @@ class phpbb_bbcode_parser_test extends \phpbb_test_case $this->markTestIncomplete($incomplete); } - global $user, $request; + global $user, $request, $symfony_request; $user = new phpbb_mock_user; $request = new phpbb_mock_request; + $symfony_request = new \phpbb\symfony_request($request); $bbcode = new bbcode_firstpass(); $bbcode->message = $message; diff --git a/tests/bbcode/url_bbcode_test.php b/tests/bbcode/url_bbcode_test.php index 3f8ad6022f..f95970a6bb 100644 --- a/tests/bbcode/url_bbcode_test.php +++ b/tests/bbcode/url_bbcode_test.php @@ -52,9 +52,10 @@ class phpbb_url_bbcode_test extends phpbb_test_case */ public function test_url($description, $message, $expected) { - global $user, $request; + global $user, $request, $symfony_request; $user = new phpbb_mock_user; $request = new phpbb_mock_request; + $symfony_request = new \phpbb\symfony_request($request); $bbcode = new bbcode_firstpass(); $bbcode->message = $message; diff --git a/tests/functions/make_clickable_email_test.php b/tests/functions/make_clickable_email_test.php index f32b4339a8..d481bde80d 100644 --- a/tests/functions/make_clickable_email_test.php +++ b/tests/functions/make_clickable_email_test.php @@ -17,9 +17,10 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case { parent::setUp(); - global $config, $user, $request; + global $config, $user, $request, $symfony_request; $user = new phpbb_mock_user(); $request = new phpbb_mock_request(); + $symfony_request = new \phpbb\symfony_request($request); } /** @@ -168,7 +169,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case array('abc,def@example.com'), // invalid character , array('abcdef@example.com', 'abc>def@example.com'), // invalid character > - + // http://fightingforalostcause.net/misc/2006/compare-email-regex.php array('missingDomain@.com'), array('@missingLocal.org'), diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php index 48fc2c19fb..a351a6d527 100644 --- a/tests/functions/make_clickable_test.php +++ b/tests/functions/make_clickable_test.php @@ -146,9 +146,10 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case { parent::setUp(); - global $config, $user, $request; + global $config, $user, $request, $symfony_request; $user = new phpbb_mock_user(); $request = new phpbb_mock_request(); + $symfony_request = new \phpbb\symfony_request($request); } /** diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index 82b1b0043b..fd9b4e4c09 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -34,7 +34,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case public function get_factory($styles_path = null) { - global $config, $phpbb_root_path, $request, $user; + global $config, $phpbb_root_path, $request, $symfony_request, $user; if (!isset($styles_path)) { @@ -69,6 +69,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case 'server_protocol' => 'http://', )); $request = new phpbb_mock_request; + $symfony_request = new \phpbb\symfony_request($request); $user = new phpbb_mock_user; return $factory; @@ -152,7 +153,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case public function test_local_url() { - global $config, $user, $request; + global $config, $user, $request, $symfony_request; $config = new \phpbb\config\config(array( 'force_server_vars' => true, 'server_protocol' => 'http://', @@ -163,6 +164,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case )); $user = new phpbb_mock_user; $request = new phpbb_mock_request; + $symfony_request = new \phpbb\symfony_request($request); $fixture = __DIR__ . '/fixtures/local_url.xml'; $renderer = $this->get_test_case_helpers()->set_s9e_services(null, $fixture)->get('text_formatter.renderer'); From 7b489638d77edeec58a1e055ad329e517c1bf6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= Date: Sun, 10 Sep 2017 13:24:10 +0200 Subject: [PATCH 3/3] [ticket/15172] Cast port to integer PHPBB3-15172 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5178c1636b..43d8cce3c4 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1661,7 +1661,7 @@ function generate_board_url($without_script_path = false) } else { - $server_port = $symfony_request->getPort(); + $server_port = (int) $symfony_request->getPort(); $forwarded_proto = $request->server('HTTP_X_FORWARDED_PROTO');