parent
95a41699cf
commit
84e900d96f
|
@ -26,6 +26,7 @@ use Friendica\Util\Proxy as ProxyUtils;
|
|||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Model\FileTag;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
require_once "include/conversation.php";
|
||||
|
||||
|
@ -162,80 +163,6 @@ function autoname($len) {
|
|||
return $word;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* escape text ($str) for XML transport
|
||||
* @param string $str
|
||||
* @return string Escaped text.
|
||||
*/
|
||||
function xmlify($str) {
|
||||
/// @TODO deprecated code found?
|
||||
/* $buffer = '';
|
||||
|
||||
$len = mb_strlen($str);
|
||||
for ($x = 0; $x < $len; $x ++) {
|
||||
$char = mb_substr($str,$x,1);
|
||||
|
||||
switch($char) {
|
||||
|
||||
case "\r" :
|
||||
break;
|
||||
case "&" :
|
||||
$buffer .= '&';
|
||||
break;
|
||||
case "'" :
|
||||
$buffer .= ''';
|
||||
break;
|
||||
case "\"" :
|
||||
$buffer .= '"';
|
||||
break;
|
||||
case '<' :
|
||||
$buffer .= '<';
|
||||
break;
|
||||
case '>' :
|
||||
$buffer .= '>';
|
||||
break;
|
||||
case "\n" :
|
||||
$buffer .= "\n";
|
||||
break;
|
||||
default :
|
||||
$buffer .= $char;
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
$buffer = mb_ereg_replace("&", "&", $str);
|
||||
$buffer = mb_ereg_replace("'", "'", $buffer);
|
||||
$buffer = mb_ereg_replace('"', """, $buffer);
|
||||
$buffer = mb_ereg_replace("<", "<", $buffer);
|
||||
$buffer = mb_ereg_replace(">", ">", $buffer);
|
||||
*/
|
||||
$buffer = htmlspecialchars($str, ENT_QUOTES, "UTF-8");
|
||||
$buffer = trim($buffer);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* undo an xmlify
|
||||
* @param string $s xml escaped text
|
||||
* @return string unescaped text
|
||||
*/
|
||||
function unxmlify($s) {
|
||||
/// @TODO deprecated code found?
|
||||
// $ret = str_replace('&','&', $s);
|
||||
// $ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret);
|
||||
/*$ret = mb_ereg_replace('&', '&', $s);
|
||||
$ret = mb_ereg_replace(''', "'", $ret);
|
||||
$ret = mb_ereg_replace('"', '"', $ret);
|
||||
$ret = mb_ereg_replace('<', "<", $ret);
|
||||
$ret = mb_ereg_replace('>', ">", $ret);
|
||||
*/
|
||||
$ret = htmlspecialchars_decode($s, ENT_QUOTES);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loader for infinite scrolling
|
||||
* @return string html for loader
|
||||
|
@ -1047,9 +974,9 @@ function get_cats_and_terms($item)
|
|||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
$categories[] = [
|
||||
'name' => xmlify(FileTag::decode($mtch[1])),
|
||||
'name' => XML::xmlify(FileTag::decode($mtch[1])),
|
||||
'url' => "#",
|
||||
'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(FileTag::decode($mtch[1])):""),
|
||||
'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . XML::xmlify(FileTag::decode($mtch[1])):""),
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
];
|
||||
|
@ -1068,9 +995,9 @@ function get_cats_and_terms($item)
|
|||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
$folders[] = [
|
||||
'name' => xmlify(FileTag::decode($mtch[1])),
|
||||
'name' => XML::xmlify(FileTag::decode($mtch[1])),
|
||||
'url' => "#",
|
||||
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . xmlify(FileTag::decode($mtch[1])) : ""),
|
||||
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . XML::xmlify(FileTag::decode($mtch[1])) : ""),
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
];
|
||||
|
@ -1234,21 +1161,6 @@ function html2bb_video($s) {
|
|||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* apply xmlify() to all values of array $val, recursively
|
||||
* @param array $val
|
||||
* @return array
|
||||
*/
|
||||
function array_xmlify($val){
|
||||
if (is_bool($val)) {
|
||||
return $val?"true":"false";
|
||||
} elseif (is_array($val)) {
|
||||
return array_map('array_xmlify', $val);
|
||||
}
|
||||
return xmlify((string) $val);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* transform link href and img src from relative to absolute
|
||||
*
|
||||
|
|
|
@ -462,4 +462,43 @@ class XML
|
|||
|
||||
return $first_item->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* escape text ($str) for XML transport
|
||||
* @param string $str
|
||||
* @return string Escaped text.
|
||||
*/
|
||||
public static function xmlify($str)
|
||||
{
|
||||
$buffer = htmlspecialchars($str, ENT_QUOTES, "UTF-8");
|
||||
$buffer = trim($buffer);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* undo an xmlify
|
||||
* @param string $s xml escaped text
|
||||
* @return string unescaped text
|
||||
*/
|
||||
public static function unxmlify($s)
|
||||
{
|
||||
$ret = htmlspecialchars_decode($s, ENT_QUOTES);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* apply xmlify() to all values of array $val, recursively
|
||||
* @param array $val
|
||||
* @return array
|
||||
*/
|
||||
public static function arrayXmlify($val)
|
||||
{
|
||||
if (is_bool($val)) {
|
||||
return $val?"true":"false";
|
||||
} elseif (is_array($val)) {
|
||||
return array_map('XML::arrayXmlify', $val);
|
||||
}
|
||||
return self::xmlify((string) $val);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user