Skip to content

Commit d73a8d9

Browse files
committed
Merge branch 'platform-health' of https://github.com/andrewbess/magento2 into CE-33574-update-laminas-escaper-composer-dependency
2 parents e44a8b0 + 057e838 commit d73a8d9

File tree

3 files changed

+73
-3
lines changed

3 files changed

+73
-3
lines changed

lib/internal/Magento/Framework/Escaper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public function escapeUrl($string)
291291
*/
292292
public function encodeUrlParam($string)
293293
{
294-
return $this->getEscaper()->escapeUrl($string);
294+
return $this->getEscaper()->escapeUrl((string)$string);
295295
}
296296

297297
/**
@@ -330,7 +330,7 @@ function ($matches) {
330330
*/
331331
public function escapeCss($string)
332332
{
333-
return $this->getEscaper()->escapeCss($string);
333+
return $this->getEscaper()->escapeCss((string)$string);
334334
}
335335

336336
/**

lib/internal/Magento/Framework/Test/Unit/EscaperTest.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,76 @@ public function testEscapeUrl(string $data, string $expected): void
364364
$this->assertEquals($expected, $this->escaper->escapeUrl($expected));
365365
}
366366

367+
/**
368+
* @covers \Magento\Framework\Escaper::escapeCss
369+
*
370+
* @param string $data
371+
* @param string $expected
372+
* @return void
373+
*
374+
* @dataProvider escapeCssDataProvider
375+
*/
376+
public function testEscapeCss($data, string $expected): void
377+
{
378+
$this->assertEquals($expected, $this->escaper->escapeCss($data));
379+
}
380+
381+
/**
382+
* @return array
383+
*/
384+
public function escapeCssDataProvider(): array
385+
{
386+
return [
387+
[
388+
'data' => 1,
389+
'expected' => '1',
390+
],
391+
[
392+
'data' => '*%string{foo}%::',
393+
'expected' => '\2A \25 string\7B foo\7D \25 \3A \3A ',
394+
]
395+
];
396+
}
397+
398+
/**
399+
* @covers \Magento\Framework\Escaper::encodeUrlParam
400+
*
401+
* @param string $data
402+
* @param string $expected
403+
* @return void
404+
*
405+
* @dataProvider encodeUrlParamDataProvider
406+
*/
407+
public function testEncodeUrlParam($data, string $expected): void
408+
{
409+
$this->assertEquals($expected, $this->escaper->encodeUrlParam($data));
410+
}
411+
412+
/**
413+
* @return array
414+
*/
415+
public function encodeUrlParamDataProvider(): array
416+
{
417+
return [
418+
[
419+
'data' => "a3==",
420+
'expected' => "a3%3D%3D",
421+
],
422+
[
423+
'data' => "example string",
424+
'expected' => "example%20string",
425+
],
426+
[
427+
'data' => 1,
428+
'expected' => "1",
429+
],
430+
[
431+
'data' => null,
432+
'expected' => "",
433+
]
434+
];
435+
}
436+
367437
/**
368438
* @return array
369439
*/

lib/internal/Magento/Framework/Url/RouteParamsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function setRouteParams(array $data, $unsetOldParams = true)
112112
} else {
113113
$this->setRouteParam(
114114
$this->getEscaper()->encodeUrlParam($key),
115-
$this->getEscaper()->encodeUrlParam($value)
115+
$this->getEscaper()->encodeUrlParam((string)$value)
116116
);
117117
}
118118
}

0 commit comments

Comments
 (0)