mirror of
https://github.com/friendica/friendica
synced 2024-11-11 04:22:53 +00:00
Replace htmlspecialchars_decode with html_entity_decode in XML::unescape
- Replace htmlspecialchars with htmlentities in XML::escape - This allows for converting all entities from Diaspora messages to regular characters
This commit is contained in:
parent
6cc376020e
commit
8fb9722cdc
1 changed files with 9 additions and 5 deletions
|
@ -4,8 +4,8 @@
|
||||||
*/
|
*/
|
||||||
namespace Friendica\Util;
|
namespace Friendica\Util;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
|
||||||
use DOMXPath;
|
use DOMXPath;
|
||||||
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use SimpleXMLElement;
|
use SimpleXMLElement;
|
||||||
|
|
||||||
|
@ -465,12 +465,13 @@ class XML
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* escape text ($str) for XML transport
|
* escape text ($str) for XML transport
|
||||||
|
*
|
||||||
* @param string $str
|
* @param string $str
|
||||||
* @return string Escaped text.
|
* @return string Escaped text.
|
||||||
*/
|
*/
|
||||||
public static function escape($str)
|
public static function escape($str)
|
||||||
{
|
{
|
||||||
$buffer = htmlspecialchars($str, ENT_QUOTES, "UTF-8");
|
$buffer = htmlentities($str, ENT_QUOTES, 'UTF-8');
|
||||||
$buffer = trim($buffer);
|
$buffer = trim($buffer);
|
||||||
|
|
||||||
return $buffer;
|
return $buffer;
|
||||||
|
@ -478,27 +479,30 @@ class XML
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* undo an escape
|
* undo an escape
|
||||||
|
*
|
||||||
* @param string $s xml escaped text
|
* @param string $s xml escaped text
|
||||||
* @return string unescaped text
|
* @return string unescaped text
|
||||||
*/
|
*/
|
||||||
public static function unescape($s)
|
public static function unescape($s)
|
||||||
{
|
{
|
||||||
$ret = htmlspecialchars_decode($s, ENT_QUOTES);
|
$ret = html_entity_decode($s, ENT_QUOTES);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* apply escape() to all values of array $val, recursively
|
* apply escape() to all values of array $val, recursively
|
||||||
|
*
|
||||||
* @param array $val
|
* @param array $val
|
||||||
* @return array
|
* @return array|string
|
||||||
*/
|
*/
|
||||||
public static function arrayEscape($val)
|
public static function arrayEscape($val)
|
||||||
{
|
{
|
||||||
if (is_bool($val)) {
|
if (is_bool($val)) {
|
||||||
return $val?"true":"false";
|
return $val ? 'true' : 'false';
|
||||||
} elseif (is_array($val)) {
|
} elseif (is_array($val)) {
|
||||||
return array_map('XML::arrayEscape', $val);
|
return array_map('XML::arrayEscape', $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::escape((string) $val);
|
return self::escape((string) $val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue