Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7755 from mautic/release-2.15.2
Release 2.15.2 to staging
- Loading branch information
Showing
41 changed files
with
1,685 additions
and
1,358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2,587 changes: 1,343 additions & 1,244 deletions
2,587
app/bundles/CoreBundle/Assets/js/libraries/3a.chosen.jquery.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* @copyright 2019 Mautic Contributors. All rights reserved | ||
* @author Mautic | ||
* | ||
* @link http://mautic.org | ||
* | ||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
namespace Mautic\CoreBundle\Helper; | ||
|
||
class Serializer | ||
{ | ||
/** | ||
* Unserializing a string can be a security vulnerability as it can contain classes that can execute a PHP code. | ||
* PHP >=7 has the `['allowed_classes' => false]` option to disable classes altogether or whitelist those needed. | ||
* PHP <7 do not accept the second parameter, throw warning and return false so we have to handle it diffenetly. | ||
* This helper method is secure for PHP >= 7 by default and handle all PHP versions. | ||
* | ||
* @param string $serializedString | ||
* @param array $options | ||
* | ||
* @return mixed | ||
*/ | ||
public static function decode($serializedString, array $options = ['allowed_classes' => false]) | ||
{ | ||
if (version_compare(phpversion(), '7.0.0', '<')) { | ||
return unserialize($serializedString); | ||
} | ||
|
||
return unserialize($serializedString, $options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* @copyright 2019 Mautic Inc. All rights reserved | ||
* @author Mautic, Inc. | ||
* | ||
* @link https://www.mautic.com | ||
* | ||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
namespace Mautic\CoreBundle\Helper; | ||
|
||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class TrailingSlashHelper | ||
{ | ||
/** | ||
* @var CoreParametersHelper | ||
*/ | ||
private $coreParametersHelper; | ||
|
||
/** | ||
* TrailingSlashHelper constructor. | ||
* | ||
* @param CoreParametersHelper $coreParametersHelper | ||
*/ | ||
public function __construct(CoreParametersHelper $coreParametersHelper) | ||
{ | ||
$this->coreParametersHelper = $coreParametersHelper; | ||
} | ||
|
||
/** | ||
* @param Request $request | ||
* | ||
* @return string | ||
*/ | ||
public function getSafeRedirectUrl(Request $request) | ||
{ | ||
$siteUrl = $this->coreParametersHelper->getParameter('site_url'); | ||
$pathInfo = substr($request->getPathInfo(), 0, -1); | ||
|
||
return $siteUrl.$pathInfo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
app/bundles/CoreBundle/Tests/unit/Helper/TrailingSlashHelperTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
/* | ||
* @copyright 2019 Mautic Inc. All rights reserved | ||
* @author Mautic, Inc. | ||
* | ||
* @link https://www.mautic.com | ||
* | ||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
namespace Mautic\CoreBundle\Tests\Helper; | ||
|
||
use Mautic\CoreBundle\Helper\CoreParametersHelper; | ||
use Mautic\CoreBundle\Helper\TrailingSlashHelper; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class TrailingSlashHelperTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var CoreParametersHelper|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $coreParametersHelper; | ||
|
||
protected function setUp() | ||
{ | ||
$this->coreParametersHelper = $this->createMock(CoreParametersHelper::class); | ||
$this->coreParametersHelper->method('getParameter') | ||
->with('site_url') | ||
->willReturn('https://test.com'); | ||
} | ||
|
||
public function testOpenRedirectIsNotPossible() | ||
{ | ||
$server = [ | ||
'HTTP_HOST' => 'test.com', | ||
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.56 Safari/537.36', | ||
'SERVER_NAME' => 'test.com', | ||
'SERVER_ADDR' => '::1', | ||
'SERVER_PORT' => '80', | ||
'REMOTE_ADDR' => '::1', | ||
'DOCUMENT_ROOT' => null, | ||
'REQUEST_SCHEME' => 'http', | ||
'REMOTE_PORT' => '80', | ||
'REDIRECT_URL' => '/google.com/', | ||
'SERVER_PROTOCOL' => 'HTTP/1.1', | ||
'REQUEST_METHOD' => 'GET', | ||
'QUERY_STRING' => '', | ||
'REQUEST_URI' => '//google.com/', | ||
'SCRIPT_NAME' => '/index.php', | ||
'PHP_SELF' => '/index.php', | ||
]; | ||
|
||
$request = new Request([], [], [], [], [], $server); | ||
|
||
// google.com should not be returned as the URL | ||
$this->assertEquals('https://test.com//google.com', $this->getHelper()->getSafeRedirectUrl($request)); | ||
} | ||
|
||
public function testMauticUrlWithTrailingSlashIsGeneratedCorrectly() | ||
{ | ||
$server = [ | ||
'HTTP_HOST' => 'test.com', | ||
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.56 Safari/537.36', | ||
'SERVER_NAME' => 'test.com', | ||
'SERVER_ADDR' => '::1', | ||
'SERVER_PORT' => '80', | ||
'REMOTE_ADDR' => '::1', | ||
'DOCUMENT_ROOT' => null, | ||
'REQUEST_SCHEME' => 'http', | ||
'REMOTE_PORT' => '80', | ||
'REDIRECT_URL' => '/s/dashboard/', | ||
'SERVER_PROTOCOL' => 'HTTP/1.1', | ||
'REQUEST_METHOD' => 'GET', | ||
'QUERY_STRING' => '', | ||
'REQUEST_URI' => '/s/dashboard/', | ||
'SCRIPT_NAME' => '/index.php', | ||
'PHP_SELF' => '/index.php', | ||
]; | ||
|
||
$request = new Request([], [], [], [], [], $server); | ||
|
||
// google.com should not be returned as the URL | ||
$this->assertEquals('https://test.com/s/dashboard', $this->getHelper()->getSafeRedirectUrl($request)); | ||
} | ||
|
||
/** | ||
* @return TrailingSlashHelper | ||
*/ | ||
private function getHelper() | ||
{ | ||
return new TrailingSlashHelper($this->coreParametersHelper); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.