Skip to content
Snippets Groups Projects
Commit 6355e57c authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#57929_la_copie_du_lien_permanent_ajoute_443' into 'stable'

hotline #57929 : do not add default port on https

See merge request !2160
parents 01fe9216 5ccc801d
Branches
Tags 7.10.4
2 merge requests!2334Master,!2160hotline #57929 : do not add default port on https
Pipeline #1525 passed with stage
in 11 minutes and 35 seconds
- ticket #57929 : Liens permanents : sur un accès en https, Bokeh n'ajoute plus le port par défaut (:443)
\ No newline at end of file
......@@ -105,6 +105,9 @@ class Class_Url {
public static function getPort() {
$port = isset($_SERVER['SERVER_PORT']) ? $_SERVER['SERVER_PORT'] : 80;
if (static::isSecure() && 443 == $port)
return '';
return $port == 80 ? '' : ':' . $port;
}
......
......@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class UrlBaseUrlTest extends PHPUnit_Framework_TestCase {
abstract class UrlTestCase extends PHPUnit_Framework_TestCase {
protected $_server_backup;
public function setUp() {
......@@ -27,12 +27,16 @@ class UrlBaseUrlTest extends PHPUnit_Framework_TestCase {
$this->_server_backup = $_SERVER;
}
public function tearDown() {
$_SERVER = $this->_server_backup;
parent::tearDown();
}
}
class UrlBaseUrlTest extends UrlTestCase {
/** @test */
public function bokehInstalledInASubdirectory() {
$_SERVER['SCRIPT_NAME'] = '/home/tom/public_html/bokeh/index.php';
......@@ -59,8 +63,39 @@ class UrlBaseUrlTest extends PHPUnit_Framework_TestCase {
/** @test */
public function absoluteUrlShouldReturnCorrectSyntax() {
$this->assertContains('http://' . $_SERVER['SERVER_NAME'] . '/', Class_Url::absolute(['module' => 'admin',
'controller' => 'cms',
'action' => 'index']));
$this->assertContains('http://' . $_SERVER['SERVER_NAME'] . '/',
Class_Url::absolute(['module' => 'admin',
'controller' => 'cms',
'action' => 'index']));
}
}
/** @see http://forge.afi-sa.fr/issues/57929 */
class UrlHttpsTest extends UrlTestCase {
public function setUp() {
parent::setUp();
$_SERVER['HTTPS'] = 'on';
}
/** @test */
public function absoluteUrlShouldNotRepeatDefaultPort() {
$_SERVER['SERVER_PORT'] = '443';
$this->assertNotContains(':443',
Class_Url::absolute(['module' => 'opac',
'controller' => 'recherche',
'action' => 'viewnotice']));
}
/** @test */
public function absoluteUrlShouldInsertExoticPort() {
$_SERVER['SERVER_PORT'] = '4433';
$this->assertContains(':4433',
Class_Url::absolute(['module' => 'opac',
'controller' => 'recherche',
'action' => 'viewnotice']));
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment