Skip to content

Commit ff99e0a

Browse files
committed
#140: Link "Read instructions on how to generate signature" in Store-Configuration is incorrect.
1 parent 69905ac commit ff99e0a

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Securitytxt/Model/Config/Signature.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
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
@@ -21,11 +21,19 @@ class Signature implements CommentInterface
2121
private $instructionLink;
2222

2323
/**
24+
* @var Escaper
25+
*/
26+
private $escaper;
27+
28+
/**
29+
* @param Escaper $escaper
2430
* @param string $instructionLink
2531
*/
2632
public function __construct(
33+
Escaper $escaper,
2734
string $instructionLink = ''
2835
) {
36+
$this->escaper = $escaper;
2937
$this->instructionLink = $instructionLink;
3038
}
3139

@@ -38,8 +46,13 @@ public function __construct(
3846
*/
3947
public function getCommentText($elementValue): string
4048
{
41-
return "<a href='{$this->instructionLink}' target='_blank'>
42-
Read instructions on how to generate signature
43-
</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+
);
4457
}
4558
}

Securitytxt/i18n/en_US.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ Hiring,Hiring
2626
"Example: https://example.com/jobs.html","Example: https://example.com/jobs.html"
2727
Policy,Policy
2828
"Example: https://example.com/security-policy.html","Example: https://example.com/security-policy.html"
29-
Signature,Signature
29+
Signature,Signature
30+
"Read instructions on how to generate signature","Read instructions on how to generate signature"

0 commit comments

Comments
 (0)