init
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleSecureHtmlRenderer\Controller\Secure;
|
||||
|
||||
use Magento\Framework\App\Action\Action;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
|
||||
/**
|
||||
* .phtml template utilizing secure-html helper.
|
||||
*/
|
||||
class Helper extends Action
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "magento/module-secure-html-renderer",
|
||||
"description": "test secure html renderer module",
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"php": "~7.4.0||~8.0.0",
|
||||
"magento/framework": "*",
|
||||
"magento/module-integration": "*"
|
||||
},
|
||||
"type": "magento2-module",
|
||||
"extra": {
|
||||
"map": [
|
||||
[
|
||||
"*",
|
||||
"Magento/TestModuleSecureHtmlRenderer"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
|
||||
<router id="standard">
|
||||
<route id="securehtml" frontName="securehtml">
|
||||
<module name="Magento_TestModuleSecureHtmlRenderer" />
|
||||
</route>
|
||||
</router>
|
||||
</config>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Magento_TestModuleSecureHtmlRenderer" active="true" />
|
||||
</config>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
$registrar = new ComponentRegistrar();
|
||||
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestModuleSecureHtmlRenderer') === null) {
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleSecureHtmlRenderer', __DIR__);
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Magento\Framework\View\Element\Template"
|
||||
name="secure_helper"
|
||||
cacheable="false"
|
||||
template="Magento_TestModuleSecureHtmlRenderer::helper.phtml" />
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
|
||||
?>
|
||||
<h1 <?= /* @noEscape */$secureRenderer->renderEventListener('onclick', 'alert()') ?>>Hello there!</h1>
|
||||
<?= /* @noEscape */ $secureRenderer->renderTag('script', ['src' => 'http://my.magento.com/static/script.js'], false); ?>
|
||||
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], "\n let myVar = 1;\n", false) ?>
|
||||
<?= /* @noEscape */ $secureRenderer->renderTag('div', [], 'I am just <a> text', true) ?>
|
||||
|
||||
Reference in New Issue
Block a user