Skip to content

Commit 26c6d67

Browse files
committed
#171: Default(pre-filled) value should be added to the "Policy" in Admin Panel for Security.txt settings
2 parents 5f9c964 + df535d1 commit 26c6d67

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

Securitytxt/Model/Config/Signature.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,40 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\Securitytxt\Model\Config;
109

1110
use Magento\Config\Model\Config\CommentInterface;
11+
use Magento\Framework\Escaper;
1212

1313
/**
1414
* Signature field description
1515
*/
1616
class Signature implements CommentInterface
1717
{
18+
/**
19+
* @var string
20+
*/
21+
private $instructionLink;
22+
23+
/**
24+
* @var Escaper
25+
*/
26+
private $escaper;
27+
28+
/**
29+
* @param Escaper $escaper
30+
* @param string $instructionLink
31+
*/
32+
public function __construct(
33+
Escaper $escaper,
34+
string $instructionLink = ''
35+
) {
36+
$this->escaper = $escaper;
37+
$this->instructionLink = $instructionLink;
38+
}
39+
1840
/**
1941
* Get comment for signature field of security txt extension.
2042
*
@@ -24,8 +46,13 @@ class Signature implements CommentInterface
2446
*/
2547
public function getCommentText($elementValue): string
2648
{
27-
return "<a href='https://devdocs.magento.com/' target='_blank'>
28-
Read instructions on how to generate signature
29-
</a>";
49+
if ($this->instructionLink === '') {
50+
return '';
51+
}
52+
return sprintf(
53+
"<a href='%s' target='_blank'>%s</a>",
54+
$this->escaper->escapeUrl($this->instructionLink),
55+
__('Read instructions on how to generate signature')
56+
);
3057
}
3158
}

Securitytxt/etc/di.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@
2222
<argument name="resultPageFactory" xsi:type="object">securitytxtResultPageFactory</argument>
2323
</arguments>
2424
</type>
25-
</config>
25+
<type name="Magento\Securitytxt\Model\Config\Signature">
26+
<arguments>
27+
<argument name="instructionLink" xsi:type="string">
28+
https://github.com/magento/security-package/blob/1.0-develop/Securitytxt/README.md
29+
</argument>
30+
</arguments>
31+
</type>
32+
</config>

Securitytxt/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ Hiring,Hiring
2626
"Example: https://example.com/jobs.html","Example: https://example.com/jobs.html"
2727
Policy,Policy
2828
Signature,Signature
29+
"Read instructions on how to generate signature","Read instructions on how to generate signature"

0 commit comments

Comments
 (0)