Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 2.16.0 to 3.x #8441

Merged
merged 14 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 27 additions & 17 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,31 @@
</IfModule>
</IfModule>

# Denie access via HTTP requests to all PHP files.
<Files "*.php">
Require all denied
</Files>
# Apache 2.4+
<IfModule authz_core_module>
# Deny access via HTTP requests to all PHP files.
<FilesMatch "\.php$">
Require all denied
</FilesMatch>

# Except those whitelisted bellow.
<FilesMatch "^(index|index_dev|filemanager|upgrade)\.php$">
Require all granted
</FilesMatch>
</IfModule>

# Fallback for Apache < 2.4
<IfModule !authz_core_module>
# Deny access via HTTP requests to all PHP files.
<FilesMatch "\.php$">
Order deny,allow
Deny from all
</FilesMatch>

# Except those whitelisted bellow.
<FilesMatch "^(index|index_dev|filemanager|upgrade)\.php$">
Order allow,deny
Allow from all
</FilesMatch>
</IfModule>

# Except those whitelisted bellow.
<Files "index.php">
Require all granted
</Files>
<Files "index_dev.php">
Require all granted
</Files>
<Files "filemanager.php">
Require all granted
</Files>
<Files "upgrade.php">
Require all granted
</Files>
2 changes: 1 addition & 1 deletion app/bundles/CoreBundle/Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@
'batch_campaign_sleep_time' => false,
'cors_restrict_domains' => true,
'cors_valid_domains' => [],
'rss_notification_url' => 'https://mautic.com/?feed=rss2&tag=notification',
'rss_notification_url' => '',
'translations_list_url' => 'https://language-packs.mautic.com/manifest.json',
'translations_fetch_url' => 'https://language-packs.mautic.com/',
'system_update_url' => 'https://updates.mautic.org/index.php?option=com_mauticdownload&task=checkUpdates',
Expand Down
46 changes: 32 additions & 14 deletions app/bundles/CoreBundle/Helper/CookieHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@

class CookieHelper
{
const SAME_SITE_NONE = '; samesite=none';
const SAME_SITE = '; SameSite=';
const SAME_SITE_VALUE = 'None';
private $path;
private $domain;
private $secure = false;
private $httponly = false;
private $secure = false;
private $httponly = false;
private $request;

/**
Expand Down Expand Up @@ -72,20 +73,37 @@ public function setCookie($name, $value, $expire = 1800, $path = null, $domain =
}

// If https, SameSite equals None
$sameSiteNoneText = '';
$sameSiteNoneText = '';
$sameSiteNoneTextGreaterPhp73 = null;
if (true === $secure or (null === $secure and true === $this->secure)) {
$sameSiteNoneText = self::SAME_SITE_NONE;
$sameSiteNoneText = self::SAME_SITE.self::SAME_SITE_VALUE;
$sameSiteNoneTextGreaterPhp73 = self::SAME_SITE_VALUE;
}

setcookie(
$name,
$value,
($expire) ? (int) (time() + $expire) : null,
((null == $path) ? $this->path : $path).$sameSiteNoneText,
(null == $domain) ? $this->domain : $domain,
(null == $secure) ? $this->secure : $secure,
(null == $httponly) ? $this->httponly : $httponly
);
if (version_compare(phpversion(), '7.3', '>=')) {
setcookie(
$name,
$value,
[
'expires' => ($expire) ? (int) (time() + $expire) : null,
'path' => ((null == $path) ? $this->path : $path),
'domain' => (null == $domain) ? $this->domain : $domain,
'secure' => (null == $secure) ? $this->secure : $secure,
'httponly' => (null == $httponly) ? $this->httponly : $httponly,
'samesite' => $sameSiteNoneTextGreaterPhp73,
]
);
} else {
setcookie(
$name,
$value,
($expire) ? (int) (time() + $expire) : null,
((null == $path) ? $this->path : $path).$sameSiteNoneText,
(null == $domain) ? $this->domain : $domain,
(null == $secure) ? $this->secure : $secure,
(null == $httponly) ? $this->httponly : $httponly
);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/bundles/CoreBundle/Tests/Unit/Helper/CookieHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testSetCookieWhenSecure()
$cookieHelper->setCookie($cookieName, 'test');

$cookie = $this->getCookie($cookieName);
$this->assertContains('samesite=none', $cookie);
$this->assertContains('SameSite=None', $cookie);
$this->assertContains('secure', $cookie);
}

Expand All @@ -75,7 +75,7 @@ public function testSetCookieWhenNotSecure()
$cookieHelper->setCookie($cookieName, 'test');

$cookie = $this->getCookie($cookieName);
$this->assertNotContains('samesite=none', $cookie);
$this->assertNotContains('SameSite=None', $cookie);
$this->assertNotContains('secure', $cookie);
}

Expand Down