Skip to content

Commit a44190b

Browse files
committed
Always emit single quotes as '
See php/php-src#6583
1 parent af44190 commit a44190b

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ Mustache for XP Framework ChangeLog
33

44
## ?.?.? / ????-??-??
55

6+
## 7.0.0 / 2021-05-02
7+
8+
* Changed single quotes to be emitted as `'` for all PHP versions.
9+
This breaks backwards compatiblity but ensure there are no security
10+
risks with expressions such as `<a href='{{url}}'>...</a>`.
11+
(@thekid)
12+
613
## 6.1.2 / 2021-05-02
714

815
* Fixed single quotes being output as `&#039;` in PHP 8.1, which changed

src/main/php/com/github/mustache/IteratorNode.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function write($context, $out) {
4848
} else {
4949
$v= $value;
5050
}
51-
$out->write($this->escape ? htmlspecialchars($v, ENT_COMPAT) : $v);
51+
$out->write($this->escape ? htmlspecialchars($v, ENT_QUOTES | ENT_SUBSTITUTE) : $v);
5252
}
5353

5454
/**

src/main/php/com/github/mustache/VariableNode.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function write($context, $out) {
9393
} else {
9494
$rendered= $context->asString($value);
9595
}
96-
$out->write($this->escape ? htmlspecialchars($rendered, ENT_COMPAT) : $rendered);
96+
$out->write($this->escape ? htmlspecialchars($rendered, ENT_QUOTES | ENT_SUBSTITUTE) : $rendered);
9797
}
9898

9999
/**

src/test/php/com/github/mustache/unittest/RenderingTest.class.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ public function html_is_escaped() {
6060
);
6161
}
6262

63-
#[Test, Values(map: ['"' => '&quot;', '<' => '&lt;', '>' => '&gt;', '&' => '&amp;', "'" => "'"])]
63+
#[Test, Values(map: ['"' => '&quot;', '<' => '&lt;', '>' => '&gt;', '&' => '&amp;', "'" => "&#039;"])]
6464
public function html_special_chars_for_variables($chars, $expected) {
6565
Assert::equals($expected, $this->render('{{input}}', ['input' => $chars]));
6666
}
6767

68-
#[Test, Values(map: ['"' => '&quot;', '<' => '&lt;', '>' => '&gt;', '&' => '&amp;', "'" => "'"])]
68+
#[Test, Values(map: ['"' => '&quot;', '<' => '&lt;', '>' => '&gt;', '&' => '&amp;', "'" => "&#039;"])]
6969
public function html_special_chars_for_iterator($chars, $expected) {
7070
Assert::equals($expected, $this->render('{{#input}}{{.}}{{/input}}', ['input' => [$chars]]));
7171
}

0 commit comments

Comments
 (0)