Skip to content

Commit a08cd58

Browse files
committed
Merge branch 'main' into designLayoutUpdates
# Conflicts: # app/design/adminhtml/base/default/layout/csp.xml # app/design/adminhtml/base/default/template/system/config/form/field/csp.phtml
2 parents 04d1503 + 0700101 commit a08cd58

File tree

52 files changed

+7396
-247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+7396
-247
lines changed

.github/spellcheck-wordlist.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
ACL
22
ActionScript
3+
analytics
34
bool
5+
boolean
6+
backorders
47
Braintree
58
Browsersync
69
Captcha
@@ -10,6 +13,7 @@ CMS
1013
Cron
1114
CVE
1215
CodeQL
16+
config
1317
DevOps
1418
DDEV
1519
DNS
@@ -18,10 +22,13 @@ EAV
1822
Emmet
1923
FireGento
2024
FPC
25+
frontend
2126
Gitpod
2227
HiPay
2328
Homebrew
2429
HMAC
30+
HTTP
31+
HTTPS
2532
ImageMagick
2633
IntelliSense
2734
jQuery
@@ -50,19 +57,25 @@ PHPStan
5057
PhpStorm
5158
PHPUnit
5259
PLAINTEXT
60+
programmatically
5361
RCE
5462
reCaptcha
5563
Redis
5664
RPC
5765
RSS
5866
RWD
67+
runtime
5968
SCSS
6069
SHA
70+
sku
71+
SKU
72+
SKUs
6173
SMTP
6274
SSL
6375
TinyMCE
6476
toc
6577
URI
78+
un
6679
Varien
6780
VMware
6881
WAMP

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Checkout
1414
uses: actions/checkout@v4
1515
- name: Check Spelling
16-
uses: rojopolis/spellcheck-github-actions@0.48.0
16+
uses: rojopolis/spellcheck-github-actions@0.51.0
1717
with:
1818
config_path: .github/spellcheck.yml
1919
task_name: Markdown

.phpstan.dist.baseline.neon

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5568,6 +5568,30 @@ parameters:
55685568
count: 1
55695569
path: app/design/adminhtml/base/default/template/system/config/form/field/array.phtml
55705570

5571+
-
5572+
message: '#^Access to protected property Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts\:\:\$_addAfter\.$#'
5573+
identifier: property.protected
5574+
count: 4
5575+
path: app/design/adminhtml/default/default/template/system/config/form/field/csp.phtml
5576+
5577+
-
5578+
message: '#^Access to protected property Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts\:\:\$_addButtonLabel\.$#'
5579+
identifier: property.protected
5580+
count: 2
5581+
path: app/design/adminhtml/default/default/template/system/config/form/field/csp.phtml
5582+
5583+
-
5584+
message: '#^Access to protected property Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts\:\:\$_columns\.$#'
5585+
identifier: property.protected
5586+
count: 5
5587+
path: app/design/adminhtml/default/default/template/system/config/form/field/csp.phtml
5588+
5589+
-
5590+
message: '#^Call to protected method _renderCellTemplate\(\) of class Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts\.$#'
5591+
identifier: method.protected
5592+
count: 2
5593+
path: app/design/adminhtml/default/default/template/system/config/form/field/csp.phtml
5594+
55715595
-
55725596
message: '#^Unreachable statement \- code above always terminates\.$#'
55735597
identifier: deadCode.unreachable
@@ -6451,7 +6475,7 @@ parameters:
64516475
path: lib/Varien/Data/Collection/Db.php
64526476

64536477
-
6454-
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(mixed\)\: bool\)\|null, Closure\(mixed\)\: array\<int\<0, max\>, string\> given\.$#'
6478+
message: '#^Parameter \#2 \$callback of function array_filter expects \(callable\(mixed\)\: bool\)\|null, Closure\(mixed\)\: array\<int\<0, max\>, non\-empty\-string\> given\.$#'
64556479
identifier: argument.type
64566480
count: 1
64576481
path: lib/Varien/Data/Collection/Db.php

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ See: https://docs.openmage.org/
2323

2424
## Sponsorship
2525

26-
* [opencollective](https://opencollective.com/openmage) [Colin Mollenhour](https://github.com/colinmollenhour))
26+
* [opencollective](https://opencollective.com/openmage) (maintained by [Colin Mollenhour](https://github.com/colinmollenhour))
2727

2828
## License
2929

app/.htaccess

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1-
Order deny,allow
2-
Deny from all
1+
<IfModule mod_authz_host.c>
2+
<IfModule !mod_authz_core.c>
3+
#Apache 2.2
4+
order deny,allow
5+
deny from all
6+
</IfModule>
7+
<IfModule mod_authz_core.c>
8+
#Apache 2.3+
9+
Require all denied
10+
</IfModule>
11+
</IfModule>

app/code/core/Mage/Adminhtml/Block/System/Config/Form/Field/Array/Abstract.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract class Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract exte
1717
/**
1818
* Grid columns
1919
*
20-
* @var array
20+
* @var array<string, array{label: string, size: string|false, style: ?string, class: ?string, renderer: Mage_Core_Block_Abstract|false}>
2121
*/
2222
protected $_columns = [];
2323

@@ -38,9 +38,9 @@ abstract class Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract exte
3838
/**
3939
* Rows cache
4040
*
41-
* @var array|null
41+
* @var array<string, Varien_Object>|null
4242
*/
43-
private $_arrayRowsCache;
43+
protected $_arrayRowsCache;
4444

4545
/**
4646
* Indication whether block is prepared to render or no
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright For copyright and license information, read the COPYING.txt file.
7+
* @link /COPYING.txt
8+
* @license Open Software License (OSL 3.0)
9+
* @package Mage_Csp
10+
*/
11+
12+
/**
13+
* Base class for CSP hosts field renderer
14+
*/
15+
class Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
16+
{
17+
protected Mage_Csp_Helper_Data $helper;
18+
19+
/**
20+
* Constructor
21+
*/
22+
public function __construct()
23+
{
24+
/** @var Mage_Csp_Helper_Data $helper */
25+
$helper = Mage::helper('csp');
26+
$this->helper = $helper;
27+
$this->addColumn('host', [
28+
'label' => Mage::helper('csp')->__('Host'),
29+
]);
30+
31+
$this->_addAfter = false;
32+
$this->_addButtonLabel = Mage::helper('csp')->__('Add Host');
33+
$this->setTemplate('system/config/form/field/csp.phtml');
34+
35+
parent::__construct();
36+
}
37+
38+
/**
39+
* Obtain existing data from form element
40+
*
41+
* Each row will be instance of Varien_Object
42+
* @return array<string, Varien_Object> Array of rows
43+
* @throws Exception
44+
*/
45+
public function getArrayRows(): array
46+
{
47+
if ($this->_arrayRowsCache !== null) {
48+
return $this->_arrayRowsCache;
49+
}
50+
51+
$result = [];
52+
53+
[$area, $directiveName] = $this->_parseNodePath();
54+
55+
$globalPolicy = $this->helper->getGlobalPolicy($directiveName);
56+
if ($globalPolicy) {
57+
foreach ($globalPolicy as $key => $host) {
58+
$rowId = $directiveName . '_xml_' . $area . '_' . $key;
59+
$result[$rowId] = new Varien_Object([
60+
'host' => $host,
61+
'readonly' => 'readonly="readonly"',
62+
'_id' => $rowId,
63+
'area' => 'global',
64+
]);
65+
$this->_prepareArrayRow($result[$rowId]);
66+
}
67+
}
68+
69+
$areaPolicy = $this->helper->getAreaPolicy($area, $directiveName);
70+
if ($areaPolicy) {
71+
foreach ($areaPolicy as $key => $host) {
72+
$rowId = $directiveName . '_xml_' . $area . '_' . $key;
73+
$result[$rowId] = new Varien_Object([
74+
'host' => $host,
75+
'readonly' => 'readonly="readonly"',
76+
'_id' => $rowId,
77+
'area' => $area,
78+
]);
79+
$this->_prepareArrayRow($result[$rowId]);
80+
}
81+
}
82+
83+
$configPolicy = $this->helper->getStoreConfigPolicy($area, $directiveName);
84+
if ($configPolicy) {
85+
foreach ($configPolicy as $key => $value) {
86+
$rowId = $directiveName . '_' . $area . '_' . $key;
87+
$result[$rowId] = new Varien_Object([
88+
'host' => $this->escapeHtml($value),
89+
'_id' => $rowId,
90+
]);
91+
92+
$this->_prepareArrayRow($result[$rowId]);
93+
}
94+
}
95+
96+
$this->_arrayRowsCache = $result;
97+
return $this->_arrayRowsCache;
98+
}
99+
100+
/**
101+
* Extract and validate area and directive name from the node path
102+
*
103+
* @return array{Mage_Core_Model_App_Area::AREA_FRONTEND|Mage_Core_Model_App_Area::AREA_ADMINHTML, value-of<Mage_Csp_Helper_Data::CSP_DIRECTIVES>} Array containing area and directiveName
104+
* @throws Exception If path format is invalid or contains disallowed values
105+
*/
106+
private function _parseNodePath(): array
107+
{
108+
/** @var Varien_Data_Form_Element_Abstract $element */
109+
$element = $this->getElement();
110+
$configPath = $element->getData('config_path');
111+
112+
$allowedDirectives = implode('|', Mage_Csp_Helper_Data::CSP_DIRECTIVES);
113+
$allowedAreas = Mage_Core_Model_App_Area::AREA_FRONTEND . '|' . Mage_Core_Model_App_Area::AREA_ADMINHTML;
114+
115+
$pattern = "#csp/({$allowedAreas})/({$allowedDirectives})#";
116+
117+
if (!$configPath || !preg_match($pattern, $configPath, $matches)) {
118+
throw new Exception('Invalid node path format or disallowed area/directive');
119+
}
120+
121+
$area = $matches[1];
122+
$directiveName = $matches[2];
123+
124+
return [$area, $directiveName];
125+
}
126+
127+
/**
128+
* Render array cell for prototypeJS template
129+
*
130+
* @param string $columnName
131+
* @return string
132+
* @throws Exception
133+
*/
134+
protected function _renderCellTemplate($columnName)
135+
{
136+
if (empty($this->_columns[$columnName])) {
137+
throw new Exception('Wrong column name specified.');
138+
}
139+
140+
$column = $this->_columns[$columnName];
141+
/** @var Varien_Data_Form_Element_Text $element */
142+
$element = $this->getElement();
143+
$elementName = $element->getName();
144+
$inputName = $elementName . '[#{_id}][' . $columnName . ']';
145+
146+
return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' .
147+
'#{readonly}' .
148+
($column['size'] ? 'size="' . $column['size'] . '"' : '') . ' class="' .
149+
($column['class'] ?? 'input-text') . '"' .
150+
(isset($column['style']) ? ' style="' . $column['style'] . '"' : '') . '/>';
151+
}
152+
}

app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Serialized.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function _afterLoad()
2020
if (!is_array($this->getValue())) {
2121
$serializedValue = $this->getValue();
2222
$unserializedValue = false;
23-
if (!empty($serializedValue)) {
23+
if (!empty($serializedValue) && is_string($serializedValue)) {
2424
try {
2525
$unserializedValue = Mage::helper('core/unserializeArray')
2626
->unserialize((string) $serializedValue);

app/code/core/Mage/Core/Model/Session/Abstract/Varien.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function start($sessionName = null)
106106
'domain' => $cookie->getConfigDomain(),
107107
'secure' => $cookie->isSecure(),
108108
'httponly' => $cookie->getHttponly(),
109+
'samesite' => $cookie->getSameSite(),
109110
];
110111

111112
if (!$cookieParams['httponly']) {
@@ -122,7 +123,7 @@ public function start($sessionName = null)
122123
$cookieParams['domain'] = $cookie->getDomain();
123124
}
124125

125-
call_user_func_array('session_set_cookie_params', array_values($cookieParams));
126+
session_set_cookie_params($cookieParams);
126127

127128
if (!empty($sessionName)) {
128129
$this->setSessionName($sessionName);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright For copyright and license information, read the COPYING.txt file.
7+
* @link /COPYING.txt
8+
* @license Open Software License (OSL 3.0)
9+
* @package Mage_Csp
10+
*/
11+
12+
/**
13+
* CSP Meta Block
14+
*
15+
* @package Mage_Csp
16+
*/
17+
class Mage_Csp_Block_Adminhtml_Meta extends Mage_Csp_Block_Meta
18+
{
19+
protected string $area = Mage_Core_Model_App_Area::AREA_ADMINHTML;
20+
}

0 commit comments

Comments
 (0)