mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-03-11 17:18:44 +00:00
Core.EscapeNonASCIICharacters now always works, even if target is UTF-8.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
parent
1255d0f15d
commit
9b10515fa4
2
NEWS
2
NEWS
@ -12,6 +12,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
4.3.1, unknown release date
|
4.3.1, unknown release date
|
||||||
# URI.Munge now munges URIs inside the same host that go from https
|
# URI.Munge now munges URIs inside the same host that go from https
|
||||||
to http. Reported by Neike Taika-Tessaro.
|
to http. Reported by Neike Taika-Tessaro.
|
||||||
|
# Core.EscapeNonASCIICharacters now always transforms entities to
|
||||||
|
entities, even if target encoding is UTF-8.
|
||||||
! Added support for 'scope' attribute on tables.
|
! Added support for 'scope' attribute on tables.
|
||||||
- Color keywords are now case insensitive. Thanks Yzmir Ramirez
|
- Color keywords are now case insensitive. Thanks Yzmir Ramirez
|
||||||
<yramirez-htmlpurifier@adicio.com> for reporting.
|
<yramirez-htmlpurifier@adicio.com> for reporting.
|
||||||
|
@ -365,12 +365,12 @@ class HTMLPurifier_Encoder
|
|||||||
*/
|
*/
|
||||||
public static function convertFromUTF8($str, $config, $context) {
|
public static function convertFromUTF8($str, $config, $context) {
|
||||||
$encoding = $config->get('Core.Encoding');
|
$encoding = $config->get('Core.Encoding');
|
||||||
if ($encoding === 'utf-8') return $str;
|
|
||||||
static $iconv = null;
|
|
||||||
if ($iconv === null) $iconv = self::iconvAvailable();
|
|
||||||
if ($escape = $config->get('Core.EscapeNonASCIICharacters')) {
|
if ($escape = $config->get('Core.EscapeNonASCIICharacters')) {
|
||||||
$str = self::convertToASCIIDumbLossless($str);
|
$str = self::convertToASCIIDumbLossless($str);
|
||||||
}
|
}
|
||||||
|
if ($encoding === 'utf-8') return $str;
|
||||||
|
static $iconv = null;
|
||||||
|
if ($iconv === null) $iconv = self::iconvAvailable();
|
||||||
if ($iconv && !$config->get('Test.ForceNoIconv')) {
|
if ($iconv && !$config->get('Test.ForceNoIconv')) {
|
||||||
// Undo our previous fix in convertToUTF8, otherwise iconv will barf
|
// Undo our previous fix in convertToUTF8, otherwise iconv will barf
|
||||||
$ascii_fix = self::testEncodingSupportsASCII($encoding);
|
$ascii_fix = self::testEncodingSupportsASCII($encoding);
|
||||||
|
@ -123,7 +123,15 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
|
|||||||
HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context),
|
HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context),
|
||||||
"中文 (Chinese)"
|
"中文 (Chinese)"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_convertFromUTF8_withProtectionButUtf8() {
|
||||||
|
// Preserve the characters!
|
||||||
|
$this->config->set('Core.EscapeNonASCIICharacters', true);
|
||||||
|
$this->assertIdentical(
|
||||||
|
HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context),
|
||||||
|
"中文 (Chinese)"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_convertToASCIIDumbLossless() {
|
function test_convertToASCIIDumbLossless() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user