File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change 8
8
namespace Magento \Csp \Block \Sri ;
9
9
10
10
use Magento \Framework \UrlInterface ;
11
+ use Magento \Deploy \Package \Package ;
11
12
use Magento \Framework \App \ObjectManager ;
12
13
use Magento \Framework \View \Element \Template ;
13
14
use Magento \Framework \Exception \LocalizedException ;
@@ -64,12 +65,22 @@ public function getSerialized(): string
64
65
{
65
66
$ result = [];
66
67
68
+ $ baseUrl = $ this ->_urlBuilder ->getBaseUrl (
69
+ ["_type " => UrlInterface::URL_TYPE_STATIC ]
70
+ );
71
+
67
72
$ integrityRepository = $ this ->integrityRepositoryPool ->get (
68
- $ this -> _appState -> getAreaCode ()
73
+ Package:: BASE_AREA
69
74
);
70
75
71
- $ baseUrl = $ this ->_urlBuilder ->getBaseUrl (
72
- ["_type " => UrlInterface::URL_TYPE_STATIC ]
76
+ foreach ($ integrityRepository ->getAll () as $ integrity ) {
77
+ $ url = $ baseUrl . $ integrity ->getPath ();
78
+
79
+ $ result [$ url ] = $ integrity ->getHash ();
80
+ }
81
+
82
+ $ integrityRepository = $ this ->integrityRepositoryPool ->get (
83
+ $ this ->_appState ->getAreaCode ()
73
84
);
74
85
75
86
foreach ($ integrityRepository ->getAll () as $ integrity ) {
Original file line number Diff line number Diff line change 8
8
namespace Magento \Csp \Plugin ;
9
9
10
10
use Magento \Framework \App \State ;
11
+ use Magento \Deploy \Package \Package ;
11
12
use Magento \Framework \View \Asset \AssetInterface ;
12
13
use Magento \Framework \View \Asset \LocalInterface ;
13
14
use Magento \Framework \View \Asset \GroupedCollection ;
@@ -56,11 +57,19 @@ public function beforeGetFilteredProperties(
56
57
): array {
57
58
if ($ asset instanceof LocalInterface) {
58
59
$ integrityRepository = $ this ->integrityRepositoryPool ->get (
59
- $ this -> state -> getAreaCode ()
60
+ Package:: BASE_AREA
60
61
);
61
62
62
63
$ integrity = $ integrityRepository ->getByPath ($ asset ->getPath ());
63
64
65
+ if (!$ integrity ) {
66
+ $ integrityRepository = $ this ->integrityRepositoryPool ->get (
67
+ $ this ->state ->getAreaCode ()
68
+ );
69
+
70
+ $ integrity = $ integrityRepository ->getByPath ($ asset ->getPath ());
71
+ }
72
+
64
73
if ($ integrity && $ integrity ->getHash ()) {
65
74
$ properties ['attributes ' ]['integrity ' ] = $ integrity ->getHash ();
66
75
$ properties ['attributes ' ]['crossorigin ' ] = 'anonymous ' ;
Original file line number Diff line number Diff line change 8
8
namespace Magento \Csp \Plugin ;
9
9
10
10
use Magento \Framework \App \Area ;
11
+ use Magento \Deploy \Package \Package ;
11
12
use Magento \Deploy \Console \DeployStaticOptions ;
12
13
use Magento \Deploy \Service \DeployStaticContent ;
13
14
use Magento \Csp \Model \SubresourceIntegrityRepositoryPool ;
@@ -46,7 +47,7 @@ public function beforeDeploy(
46
47
array $ options
47
48
): void {
48
49
if (PHP_SAPI == 'cli ' && !$ this ->isRefreshContentVersionOnly ($ options )) {
49
- foreach ([Area::AREA_FRONTEND , Area::AREA_ADMINHTML ] as $ area ) {
50
+ foreach ([Package:: BASE_AREA , Area::AREA_FRONTEND , Area::AREA_ADMINHTML ] as $ area ) {
50
51
$ this ->integrityRepositoryPool ->get ($ area )
51
52
->deleteAll ();
52
53
}
You can’t perform that action at this time.
0 commit comments