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

Fix incompatibility with laminas-escaper (2.7.1) #33353

Merged
merged 5 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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 lib/internal/Magento/Framework/Escaper.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function escapeUrl($string)
* @return string
* @since 101.0.0
*/
public function encodeUrlParam($string)
public function encodeUrlParam(string $string)
{
return $this->getEscaper()->escapeUrl($string);
}
ihor-sviziev marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -328,7 +328,7 @@ function ($matches) {
* @return string
* @since 101.0.0
*/
public function escapeCss($string)
public function escapeCss(string $string)
{
return $this->getEscaper()->escapeCss($string);
}
ihor-sviziev marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
58 changes: 58 additions & 0 deletions lib/internal/Magento/Framework/Test/Unit/EscaperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,64 @@ public function testEscapeUrl(string $data, string $expected): void
$this->assertEquals($expected, $this->escaper->escapeUrl($expected));
}

/**
* @covers \Magento\Framework\Escaper::escapeCss
*
* @param string $data
* @param string $expected
* @return void
*
* @dataProvider escapeCssDataProvider
*/
public function testEscapeCss($data, string $expected): void
{
$this->assertEquals($expected, $this->escaper->escapeCss($data));
}

/**
* @return array
*/
public function escapeCssDataProvider(): array
{
return [
[
'data' => '*%string{foo}%::',
'expected' => '\2A \25 string\7B foo\7D \25 \3A \3A ',
]
];
ihor-sviziev marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @covers \Magento\Framework\Escaper::encodeUrlParam
*
* @param string $data
* @param string $expected
* @return void
*
* @dataProvider encodeUrlParamDataProvider
*/
public function testEncodeUrlParam($data, string $expected): void
{
$this->assertEquals($expected, $this->escaper->encodeUrlParam($data));
}

/**
* @return array
*/
public function encodeUrlParamDataProvider(): array
{
return [
[
'data' => "a3==",
'expected' => "a3%3D%3D",
],
[
'data' => "example string",
'expected' => "example%20string",
]
];
ihor-sviziev marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @return array
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/Url/RouteParamsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function setRouteParams(array $data, $unsetOldParams = true)
} else {
$this->setRouteParam(
$this->getEscaper()->encodeUrlParam($key),
$this->getEscaper()->encodeUrlParam($value)
$this->getEscaper()->encodeUrlParam((string)$value)
ihor-sviziev marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
Expand Down