Skip to content

Commit 4950a85

Browse files
authored
Merge pull request #16124 from niden/T16123-html-attributes
T16123 html attributes
2 parents fcfe216 + 97d918f commit 4950a85

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

CHANGELOG-5.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# [5.0.2](https://github.com/phalcon/cphalcon/releases/tag/v5.0.2) (2022-09-27)
2+
3+
## Fixed
4+
- Fixed `Phalcon\Html\Escaper::attributes()` to accept any value and transform it to string [#16123](https://github.com/phalcon/cphalcon/issues/16123)
5+
- Fixed `Phalcon\Logger\AbstractLogger::getLevelNumber()` to better check for string levels [#16123](https://github.com/phalcon/cphalcon/issues/16123)
6+
17
# [5.0.1](https://github.com/phalcon/cphalcon/releases/tag/v5.0.1) (2022-09-23)
28

39
## Fixed

phalcon/Html/Escaper.zep

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,8 @@ class Escaper implements EscaperInterface
6666
{
6767
var key, result, value;
6868

69-
if (typeof input !== "string" && typeof input !== "array") {
70-
throw new Exception("Input must be an array or a string");
71-
}
72-
73-
if (typeof input === "string") {
74-
return this->phpHtmlSpecialChars(input);
69+
if likely (typeof input !== "array") {
70+
return this->phpHtmlSpecialChars((string) input);
7571
}
7672

7773
let result = "";
@@ -86,11 +82,11 @@ class Escaper implements EscaperInterface
8682
let value = implode(" ", value);
8783
}
8884

89-
let result .= this->phpHtmlSpecialChars(key);
85+
let result .= this->phpHtmlSpecialChars((string) key);
9086

9187
if (true !== value) {
9288
let result .= "=\""
93-
. this->phpHtmlSpecialChars(value)
89+
. this->phpHtmlSpecialChars((string) value)
9490
. "\"";
9591
}
9692

phalcon/Logger/AbstractLogger.zep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,14 @@ abstract class AbstractLogger
313313
*
314314
* @return int
315315
*/
316-
protected function getLevelNumber(level) -> int
316+
protected function getLevelNumber(var level) -> int
317317
{
318318
var levelName, levels;
319319

320320
/**
321321
* If someone uses "critical" as the level (string)
322322
*/
323-
if (true === is_string(level)) {
323+
if (typeof level === "string") {
324324
let levelName = strtoupper(level),
325325
levels = array_flip(this->getLevels());
326326

tests/unit/Html/Escaper/AttributesCest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ private function escaperEscapeHtmlAttrProvider(): array
7777
'expected' => 'That's right',
7878
'text' => "That's right",
7979
],
80+
[
81+
'htmlQuoteType' => ENT_HTML5,
82+
'expected' => '10',
83+
'text' => 10,
84+
],
85+
[
86+
'htmlQuoteType' => ENT_HTML5,
87+
'expected' => 'maxlength="10" cols="5" rows="3" min="1" max="100"',
88+
'text' => [
89+
'maxlength' => 10,
90+
'cols' => 5,
91+
'rows' => 3,
92+
'min' => 1,
93+
'max' => 100,
94+
'notPrinted' => false,
95+
'notPrinted2' => null,
96+
],
97+
],
8098
[
8199
'htmlQuoteType' => ENT_HTML5,
82100
'expected' => 'text="Ferrari Ford Dodge"',

0 commit comments

Comments
 (0)