Skip to content

Commit

Permalink
Rename inlineStyle to cspInlineStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Jan 20, 2024
1 parent f991bbd commit 6de2fdd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core-bundle/contao/library/Contao/TemplateTrait.php
Expand Up @@ -195,7 +195,7 @@ public function addCspHash(string $directive, string $script, string $algorithm
/**
* Adds a CSP hash for a given inline style and also adds the 'unsafe-hashes' source to the directive automatically.
*/
public function inlineStyle(string $style, string $algorithm = 'sha384'): string
public function cspInlineStyle(string $style, string $algorithm = 'sha384'): string
{
$responseContext = System::getContainer()->get('contao.routing.response_context_accessor')->getResponseContext();

Expand Down
2 changes: 1 addition & 1 deletion core-bundle/contao/templates/forms/form_captcha.html5
Expand Up @@ -18,7 +18,7 @@
<input type="hidden" name="<?= $this->name ?>_hash" value="<?= $this->hasErrors() ? $this->getHash() : '' ?>">

<?php if (!$this->hasErrors()): ?>
<div style="<?= $this->inlineStyle('display:none') ?>">
<div style="<?= $this->cspInlineStyle('display:none') ?>">
<label for="ctrl_<?= $this->id ?>_hp">Do not fill in this field</label>
<input type="text" name="<?= $this->name ?>_name" id="ctrl_<?= $this->id ?>_hp" value="">
</div>
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/contao/templates/modules/mod_two_factor.html5
Expand Up @@ -20,7 +20,7 @@
</div>
<div class="widget">
<p><?= $this->trans('MSC.twoFactorTextCode') ?></p>
<code style="<?= $this->inlineStyle('word-break:break-all') ?>"><?= $this->secret ?></code>
<code style="<?= $this->cspInlineStyle('word-break:break-all') ?>"><?= $this->secret ?></code>
</div>
<div class="widget widget-text">
<label for="verify"><?= $this->trans('MSC.twoFactorVerification') ?></label>
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/tests/Contao/TemplateTest.php
Expand Up @@ -524,7 +524,7 @@ public function testAddsCspInlineStyleHash(): void
$style = 'display:none';
$algorithm = 'sha384';

$result = (new FrontendTemplate())->inlineStyle($style, $algorithm);
$result = (new FrontendTemplate())->cspInlineStyle($style, $algorithm);

$response = new Response();
$cspHandler->applyHeaders($response);
Expand Down
2 changes: 1 addition & 1 deletion core-bundle/tests/Twig/FragmentTemplateTest.php
Expand Up @@ -78,7 +78,7 @@ public function testDisallowsAccessOfParentMethods(string $method, array $args):

public function provideIllegalParentMethods(): \Generator
{
$excluded = ['__construct', '__set', '__get', '__isset', 'setData', 'getData', 'setName', 'getName', 'getResponse', 'addCspSource', 'addCspHash', 'inlineStyle', 'cspInlineStyles', 'nonce', 'attr'];
$excluded = ['__construct', '__set', '__get', '__isset', 'setData', 'getData', 'setName', 'getName', 'getResponse', 'addCspSource', 'addCspHash', 'cspInlineStyle', 'cspInlineStyles', 'nonce', 'attr'];
$parent = (new \ReflectionClass(FragmentTemplate::class))->getParentClass();

foreach ($parent->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
Expand Down

0 comments on commit 6de2fdd

Please sign in to comment.