Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow bool $doubleEncode optional param to escapeHtml() #54

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Escaper.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@
{
if ($encoding !== null) {
if ($encoding === '') {
throw new Exception\InvalidArgumentException(

Check warning on line 140 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "Throw_": --- Original +++ New @@ @@ { if ($encoding !== null) { if ($encoding === '') { - throw new Exception\InvalidArgumentException(static::class . ' constructor parameter does not allow a blank value'); + new Exception\InvalidArgumentException(static::class . ' constructor parameter does not allow a blank value'); } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) {
static::class . ' constructor parameter does not allow a blank value'

Check warning on line 141 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "Concat": --- Original +++ New @@ @@ { if ($encoding !== null) { if ($encoding === '') { - throw new Exception\InvalidArgumentException(static::class . ' constructor parameter does not allow a blank value'); + throw new Exception\InvalidArgumentException(' constructor parameter does not allow a blank value' . static::class); } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) {

Check warning on line 141 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "ConcatOperandRemoval": --- Original +++ New @@ @@ { if ($encoding !== null) { if ($encoding === '') { - throw new Exception\InvalidArgumentException(static::class . ' constructor parameter does not allow a blank value'); + throw new Exception\InvalidArgumentException(' constructor parameter does not allow a blank value'); } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) {

Check warning on line 141 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "ConcatOperandRemoval": --- Original +++ New @@ @@ { if ($encoding !== null) { if ($encoding === '') { - throw new Exception\InvalidArgumentException(static::class . ' constructor parameter does not allow a blank value'); + throw new Exception\InvalidArgumentException(static::class); } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) {
);
}

$encoding = strtolower($encoding);
if (! in_array($encoding, $this->supportedEncodings)) {
throw new Exception\InvalidArgumentException(
'Value of \'' . $encoding . '\' passed to ' . static::class

Check warning on line 148 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "Concat": --- Original +++ New @@ @@ } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) { - throw new Exception\InvalidArgumentException('Value of \'' . $encoding . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); + throw new Exception\InvalidArgumentException($encoding . 'Value of \'' . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); } $this->encoding = $encoding; }

Check warning on line 148 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "ConcatOperandRemoval": --- Original +++ New @@ @@ } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) { - throw new Exception\InvalidArgumentException('Value of \'' . $encoding . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); + throw new Exception\InvalidArgumentException($encoding . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); } $this->encoding = $encoding; }

Check warning on line 148 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "ConcatOperandRemoval": --- Original +++ New @@ @@ } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) { - throw new Exception\InvalidArgumentException('Value of \'' . $encoding . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); + throw new Exception\InvalidArgumentException('Value of \'' . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); } $this->encoding = $encoding; }

Check warning on line 148 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "Concat": --- Original +++ New @@ @@ } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) { - throw new Exception\InvalidArgumentException('Value of \'' . $encoding . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); + throw new Exception\InvalidArgumentException('Value of \'' . '\' passed to ' . $encoding . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); } $this->encoding = $encoding; }

Check warning on line 148 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "ConcatOperandRemoval": --- Original +++ New @@ @@ } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) { - throw new Exception\InvalidArgumentException('Value of \'' . $encoding . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); + throw new Exception\InvalidArgumentException('Value of \'' . $encoding . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); } $this->encoding = $encoding; }

Check warning on line 148 in src/Escaper.php

View workflow job for this annotation

GitHub Actions / ci / QA Checks (Infection [8.1, locked], ubuntu-latest, laminas/laminas-continuous-integration-action@...

Escaped Mutant for Mutator "Concat": --- Original +++ New @@ @@ } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) { - throw new Exception\InvalidArgumentException('Value of \'' . $encoding . '\' passed to ' . static::class . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); + throw new Exception\InvalidArgumentException('Value of \'' . $encoding . static::class . '\' passed to ' . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'); } $this->encoding = $encoding; }
. ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'
);
}
Expand Down Expand Up @@ -190,9 +190,9 @@
*
* @return string
*/
public function escapeHtml(string $string)
public function escapeHtml(string $string, bool $doubleEncode = true)
{
return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding);
return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding, $doubleEncode);
}

/**
Expand Down