File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Test/Unit/Controller/Result Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public function __construct(ScopeConfigInterface $scopeConfig)
39
39
*/
40
40
public function beforeSendResponse (Http $ subject )
41
41
{
42
- $ content = $ subject ->getContent ();
42
+ $ content = $ subject ->getContent () ?? '' ;
43
43
44
44
$ bodyClose = '</body ' ;
45
45
@@ -57,6 +57,11 @@ public function beforeSendResponse(Http $subject)
57
57
$ scriptClosePos = strpos ($ content , $ scriptClose , $ scriptOpenPos );
58
58
$ script = substr ($ content , $ scriptOpenPos , $ scriptClosePos - $ scriptOpenPos + strlen ($ scriptClose ));
59
59
60
+ if (strpos ($ script , 'text/x-magento-template ' ) !== false ) {
61
+ $ scriptOpenPos = strpos ($ content , $ scriptOpen , $ scriptClosePos );
62
+ continue ;
63
+ }
64
+
60
65
$ scripts .= "\n" . $ script ;
61
66
$ content = str_replace ($ script , '' , $ content );
62
67
// Script cut out, continue search from its position.
Original file line number Diff line number Diff line change @@ -74,9 +74,9 @@ public function sendResponseDataProvider(): array
74
74
"flag " => true ,
75
75
"result " => "<body><h1>Test Title</h1> " .
76
76
"<script type= \"text/x-magento-template \">test</script> " .
77
- "<p>Test Content</p> " .
78
- "<script type= \"text/x-magento-init \">test</script> " .
79
- "\n </body> "
77
+ "<p>Test Content</p> \n " .
78
+ "<script type= \"text/x-magento-init \">test</script> \n " .
79
+ "</body> "
80
80
],
81
81
'content_with_config_disable ' => [
82
82
"content " => "<body><p>Test Content</p></body> " ,
You can’t perform that action at this time.
0 commit comments