notags calls

implement removeTags function
This commit is contained in:
Adam Magness
2018-11-08 10:14:37 -05:00
parent 991f259ecb
commit a0f65ca7a1
51 changed files with 274 additions and 232 deletions

View File

@@ -1150,7 +1150,7 @@ class Item extends BaseObject
private static function guid($item, $notify)
{
if (!empty($item['guid'])) {
return notags(trim($item['guid']));
return Strings::removeTags(trim($item['guid']));
}
if ($notify) {
@@ -1265,7 +1265,7 @@ class Item extends BaseObject
}
$item['guid'] = self::guid($item, $notify);
$item['uri'] = notags(trim(defaults($item, 'uri', self::newURI($item['uid'], $item['guid']))));
$item['uri'] = Strings::removeTags(trim(defaults($item, 'uri', self::newURI($item['uid'], $item['guid']))));
// Store URI data
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);

View File

@@ -25,6 +25,7 @@ use Friendica\Protocol\Diaspora;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
require_once 'include/dba.php';
@@ -881,7 +882,7 @@ class Profile
$tab = false;
if (x($_GET, 'tab')) {
$tab = notags(trim($_GET['tab']));
$tab = Strings::removeTags(trim($_GET['tab']));
}
$url = System::baseUrl() . '/profile/' . $nickname;

View File

@@ -20,6 +20,7 @@ use Friendica\Object\Image;
use Friendica\Util\Crypto;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings;
use LightOpenID;
require_once 'boot.php';
@@ -401,18 +402,18 @@ class User
$using_invites = Config::get('system', 'invitation_only');
$num_invites = Config::get('system', 'number_invites');
$invite_id = !empty($data['invite_id']) ? notags(trim($data['invite_id'])) : '';
$username = !empty($data['username']) ? notags(trim($data['username'])) : '';
$nickname = !empty($data['nickname']) ? notags(trim($data['nickname'])) : '';
$email = !empty($data['email']) ? notags(trim($data['email'])) : '';
$openid_url = !empty($data['openid_url']) ? notags(trim($data['openid_url'])) : '';
$photo = !empty($data['photo']) ? notags(trim($data['photo'])) : '';
$invite_id = !empty($data['invite_id']) ? Strings::removeTags(trim($data['invite_id'])) : '';
$username = !empty($data['username']) ? Strings::removeTags(trim($data['username'])) : '';
$nickname = !empty($data['nickname']) ? Strings::removeTags(trim($data['nickname'])) : '';
$email = !empty($data['email']) ? Strings::removeTags(trim($data['email'])) : '';
$openid_url = !empty($data['openid_url']) ? Strings::removeTags(trim($data['openid_url'])) : '';
$photo = !empty($data['photo']) ? Strings::removeTags(trim($data['photo'])) : '';
$password = !empty($data['password']) ? trim($data['password']) : '';
$password1 = !empty($data['password1']) ? trim($data['password1']) : '';
$confirm = !empty($data['confirm']) ? trim($data['confirm']) : '';
$blocked = !empty($data['blocked']) ? intval($data['blocked']) : 0;
$verified = !empty($data['verified']) ? intval($data['verified']) : 0;
$language = !empty($data['language']) ? notags(trim($data['language'])) : 'en';
$language = !empty($data['language']) ? Strings::removeTags(trim($data['language'])) : 'en';
$publish = !empty($data['profile_publish_reg']) && intval($data['profile_publish_reg']) ? 1 : 0;
$netpublish = strlen(Config::get('system', 'directory')) ? $publish : 0;

View File

@@ -22,6 +22,7 @@ use Friendica\Module\Login;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\Strings;
/**
* Manages and show Contacts and their content
@@ -601,7 +602,7 @@ class Contact extends BaseModule
'$lbl_vis2' => L10n::t('Please choose the profile you would like to display to %s when viewing your profile securely.', $contact['name']),
'$lbl_info1' => $lbl_info1,
'$lbl_info2' => L10n::t('Their personal note'),
'$reason' => trim(notags($contact['reason'])),
'$reason' => trim(Strings::removeTags($contact['reason'])),
'$infedit' => L10n::t('Edit contact notes'),
'$common_link' => 'common/loc/' . local_user() . '/' . $contact['id'],
'$relation_text' => $relation_text,
@@ -694,8 +695,8 @@ class Contact extends BaseModule
$sql_extra .= sprintf(" AND `network` != '%s' ", Protocol::PHANTOM);
$search = notags(trim(defaults($_GET, 'search', '')));
$nets = notags(trim(defaults($_GET, 'nets' , '')));
$search = Strings::removeTags(trim(defaults($_GET, 'search', '')));
$nets = Strings::removeTags(trim(defaults($_GET, 'nets' , '')));
$tabs = [
[

View File

@@ -9,6 +9,7 @@ use Friendica\Database\DBStructure;
use Friendica\Core;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Util\Strings;
use Friendica\Util\Temporal;
class Install extends BaseModule
@@ -70,10 +71,10 @@ class Install extends BaseModule
break;
case self::SITE_SETTINGS:
$dbhost = notags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST)));
$dbuser = notags(trim(defaults($_POST, 'dbuser', '')));
$dbpass = notags(trim(defaults($_POST, 'dbpass', '')));
$dbdata = notags(trim(defaults($_POST, 'dbdata', '')));
$dbhost = Strings::removeTags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST)));
$dbuser = Strings::removeTags(trim(defaults($_POST, 'dbuser', '')));
$dbpass = Strings::removeTags(trim(defaults($_POST, 'dbpass', '')));
$dbdata = Strings::removeTags(trim(defaults($_POST, 'dbdata', '')));
// If we cannot connect to the database, return to the previous step
if (!self::$installer->checkDB($dbhost, $dbuser, $dbpass, $dbdata)) {
@@ -84,13 +85,13 @@ class Install extends BaseModule
case self::FINISHED:
$urlpath = $a->getURLPath();
$dbhost = notags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST)));
$dbuser = notags(trim(defaults($_POST, 'dbuser', '')));
$dbpass = notags(trim(defaults($_POST, 'dbpass', '')));
$dbdata = notags(trim(defaults($_POST, 'dbdata', '')));
$timezone = notags(trim(defaults($_POST, 'timezone', Core\Installer::DEFAULT_TZ)));
$language = notags(trim(defaults($_POST, 'language', Core\Installer::DEFAULT_LANG)));
$adminmail = notags(trim(defaults($_POST, 'adminmail', '')));
$dbhost = Strings::removeTags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST)));
$dbuser = Strings::removeTags(trim(defaults($_POST, 'dbuser', '')));
$dbpass = Strings::removeTags(trim(defaults($_POST, 'dbpass', '')));
$dbdata = Strings::removeTags(trim(defaults($_POST, 'dbdata', '')));
$timezone = Strings::removeTags(trim(defaults($_POST, 'timezone', Core\Installer::DEFAULT_TZ)));
$language = Strings::removeTags(trim(defaults($_POST, 'language', Core\Installer::DEFAULT_LANG)));
$adminmail = Strings::removeTags(trim(defaults($_POST, 'adminmail', '')));
// If we cannot connect to the database, return to the Database config wizard
if (!self::$installer->checkDB($dbhost, $dbuser, $dbpass, $dbdata)) {
@@ -139,12 +140,12 @@ class Install extends BaseModule
break;
case self::DATABASE_CONFIG:
$dbhost = notags(trim(defaults($_POST, 'dbhost' , Core\Installer::DEFAULT_HOST)));
$dbuser = notags(trim(defaults($_POST, 'dbuser' , '' )));
$dbpass = notags(trim(defaults($_POST, 'dbpass' , '' )));
$dbdata = notags(trim(defaults($_POST, 'dbdata' , '' )));
$phpath = notags(trim(defaults($_POST, 'phpath' , '' )));
$adminmail = notags(trim(defaults($_POST, 'adminmail', '' )));
$dbhost = Strings::removeTags(trim(defaults($_POST, 'dbhost' , Core\Installer::DEFAULT_HOST)));
$dbuser = Strings::removeTags(trim(defaults($_POST, 'dbuser' , '' )));
$dbpass = Strings::removeTags(trim(defaults($_POST, 'dbpass' , '' )));
$dbdata = Strings::removeTags(trim(defaults($_POST, 'dbdata' , '' )));
$phpath = Strings::removeTags(trim(defaults($_POST, 'phpath' , '' )));
$adminmail = Strings::removeTags(trim(defaults($_POST, 'adminmail', '' )));
$tpl = Renderer::getMarkupTemplate('install_db.tpl');
$output .= Renderer::replaceMacros($tpl, [
@@ -190,13 +191,13 @@ class Install extends BaseModule
break;
case self::SITE_SETTINGS:
$dbhost = notags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST)));
$dbuser = notags(trim(defaults($_POST, 'dbuser', '' )));
$dbpass = notags(trim(defaults($_POST, 'dbpass', '' )));
$dbdata = notags(trim(defaults($_POST, 'dbdata', '' )));
$phpath = notags(trim(defaults($_POST, 'phpath', '' )));
$dbhost = Strings::removeTags(trim(defaults($_POST, 'dbhost', Core\Installer::DEFAULT_HOST)));
$dbuser = Strings::removeTags(trim(defaults($_POST, 'dbuser', '' )));
$dbpass = Strings::removeTags(trim(defaults($_POST, 'dbpass', '' )));
$dbdata = Strings::removeTags(trim(defaults($_POST, 'dbdata', '' )));
$phpath = Strings::removeTags(trim(defaults($_POST, 'phpath', '' )));
$adminmail = notags(trim(defaults($_POST, 'adminmail', '')));
$adminmail = Strings::removeTags(trim(defaults($_POST, 'adminmail', '')));
$timezone = defaults($_POST, 'timezone', Core\Installer::DEFAULT_TZ);
/* Installed langs */

View File

@@ -17,6 +17,7 @@ use Friendica\Database\DBA;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings;
use LightOpenID;
require_once 'boot.php';
@@ -148,7 +149,7 @@ class Login extends BaseModule
);
}
} catch (Exception $e) {
Logger::log('authenticate: failed login attempt: ' . notags($username) . ' from IP ' . $_SERVER['REMOTE_ADDR']);
Logger::log('authenticate: failed login attempt: ' . Strings::removeTags($username) . ' from IP ' . $_SERVER['REMOTE_ADDR']);
info('Login failed. Please check your credentials.' . EOL);
$a->internalRedirect();
}

View File

@@ -1674,7 +1674,7 @@ class Probe
}
}
$data["name"] = notags($data["name"]);
$data["name"] = Strings::removeTags($data["name"]);
}
}
}

View File

@@ -2494,7 +2494,7 @@ class DFRN
$item["body"] = XML::getFirstNodeValue($xpath, "dfrn:env/text()", $entry);
$item["body"] = str_replace([' ',"\t","\r","\n"], ['','','',''], $item["body"]);
// make sure nobody is trying to sneak some html tags by us
$item["body"] = notags(base64url_decode($item["body"]));
$item["body"] = Strings::removeTags(base64url_decode($item["body"]));
$item["body"] = BBCode::limitBodySize($item["body"]);

View File

@@ -1506,9 +1506,9 @@ class Diaspora
*/
private static function receiveAccountMigration(array $importer, $data)
{
$old_handle = notags(XML::unescape($data->author));
$new_handle = notags(XML::unescape($data->profile->author));
$signature = notags(XML::unescape($data->signature));
$old_handle = Strings::removeTags(XML::unescape($data->author));
$new_handle = Strings::removeTags(XML::unescape($data->profile->author));
$signature = Strings::removeTags(XML::unescape($data->signature));
$contact = self::contactByHandle($importer["uid"], $old_handle);
if (!$contact) {
@@ -1566,7 +1566,7 @@ class Diaspora
*/
private static function receiveAccountDeletion($data)
{
$author = notags(XML::unescape($data->author));
$author = Strings::removeTags(XML::unescape($data->author));
$contacts = DBA::select('contact', ['id'], ['addr' => $author]);
while ($contact = DBA::fetch($contacts)) {
@@ -1657,19 +1657,19 @@ class Diaspora
*/
private static function receiveComment(array $importer, $sender, $data, $xml)
{
$author = notags(XML::unescape($data->author));
$guid = notags(XML::unescape($data->guid));
$parent_guid = notags(XML::unescape($data->parent_guid));
$author = Strings::removeTags(XML::unescape($data->author));
$guid = Strings::removeTags(XML::unescape($data->guid));
$parent_guid = Strings::removeTags(XML::unescape($data->parent_guid));
$text = XML::unescape($data->text);
if (isset($data->created_at)) {
$created_at = DateTimeFormat::utc(notags(XML::unescape($data->created_at)));
$created_at = DateTimeFormat::utc(Strings::removeTags(XML::unescape($data->created_at)));
} else {
$created_at = DateTimeFormat::utcNow();
}
if (isset($data->thread_parent_guid)) {
$thread_parent_guid = notags(XML::unescape($data->thread_parent_guid));
$thread_parent_guid = Strings::removeTags(XML::unescape($data->thread_parent_guid));
$thr_uri = self::getUriFromGuid("", $thread_parent_guid, true);
} else {
$thr_uri = "";
@@ -1774,24 +1774,24 @@ class Diaspora
*/
private static function receiveConversationMessage(array $importer, array $contact, $data, $msg, $mesg, $conversation)
{
$author = notags(XML::unescape($data->author));
$guid = notags(XML::unescape($data->guid));
$subject = notags(XML::unescape($data->subject));
$author = Strings::removeTags(XML::unescape($data->author));
$guid = Strings::removeTags(XML::unescape($data->guid));
$subject = Strings::removeTags(XML::unescape($data->subject));
// "diaspora_handle" is the element name from the old version
// "author" is the element name from the new version
if ($mesg->author) {
$msg_author = notags(XML::unescape($mesg->author));
$msg_author = Strings::removeTags(XML::unescape($mesg->author));
} elseif ($mesg->diaspora_handle) {
$msg_author = notags(XML::unescape($mesg->diaspora_handle));
$msg_author = Strings::removeTags(XML::unescape($mesg->diaspora_handle));
} else {
return false;
}
$msg_guid = notags(XML::unescape($mesg->guid));
$msg_conversation_guid = notags(XML::unescape($mesg->conversation_guid));
$msg_guid = Strings::removeTags(XML::unescape($mesg->guid));
$msg_conversation_guid = Strings::removeTags(XML::unescape($mesg->conversation_guid));
$msg_text = XML::unescape($mesg->text);
$msg_created_at = DateTimeFormat::utc(notags(XML::unescape($mesg->created_at)));
$msg_created_at = DateTimeFormat::utc(Strings::removeTags(XML::unescape($mesg->created_at)));
if ($msg_conversation_guid != $guid) {
Logger::log("message conversation guid does not belong to the current conversation.");
@@ -1862,11 +1862,11 @@ class Diaspora
*/
private static function receiveConversation(array $importer, $msg, $data)
{
$author = notags(XML::unescape($data->author));
$guid = notags(XML::unescape($data->guid));
$subject = notags(XML::unescape($data->subject));
$created_at = DateTimeFormat::utc(notags(XML::unescape($data->created_at)));
$participants = notags(XML::unescape($data->participants));
$author = Strings::removeTags(XML::unescape($data->author));
$guid = Strings::removeTags(XML::unescape($data->guid));
$subject = Strings::removeTags(XML::unescape($data->subject));
$created_at = DateTimeFormat::utc(Strings::removeTags(XML::unescape($data->created_at)));
$participants = Strings::removeTags(XML::unescape($data->participants));
$messages = $data->message;
@@ -1920,11 +1920,11 @@ class Diaspora
*/
private static function receiveLike(array $importer, $sender, $data)
{
$author = notags(XML::unescape($data->author));
$guid = notags(XML::unescape($data->guid));
$parent_guid = notags(XML::unescape($data->parent_guid));
$parent_type = notags(XML::unescape($data->parent_type));
$positive = notags(XML::unescape($data->positive));
$author = Strings::removeTags(XML::unescape($data->author));
$guid = Strings::removeTags(XML::unescape($data->guid));
$parent_guid = Strings::removeTags(XML::unescape($data->parent_guid));
$parent_type = Strings::removeTags(XML::unescape($data->parent_type));
$positive = Strings::removeTags(XML::unescape($data->positive));
// likes on comments aren't supported by Diaspora - only on posts
// But maybe this will be supported in the future, so we will accept it.
@@ -2029,11 +2029,11 @@ class Diaspora
*/
private static function receiveMessage(array $importer, $data)
{
$author = notags(XML::unescape($data->author));
$guid = notags(XML::unescape($data->guid));
$conversation_guid = notags(XML::unescape($data->conversation_guid));
$author = Strings::removeTags(XML::unescape($data->author));
$guid = Strings::removeTags(XML::unescape($data->guid));
$conversation_guid = Strings::removeTags(XML::unescape($data->conversation_guid));
$text = XML::unescape($data->text);
$created_at = DateTimeFormat::utc(notags(XML::unescape($data->created_at)));
$created_at = DateTimeFormat::utc(Strings::removeTags(XML::unescape($data->created_at)));
$contact = self::allowedContactByHandle($importer, $author, true);
if (!$contact) {
@@ -2104,8 +2104,8 @@ class Diaspora
*/
private static function receiveParticipation(array $importer, $data)
{
$author = strtolower(notags(XML::unescape($data->author)));
$parent_guid = notags(XML::unescape($data->parent_guid));
$author = strtolower(Strings::removeTags(XML::unescape($data->author)));
$parent_guid = Strings::removeTags(XML::unescape($data->parent_guid));
$contact_id = Contact::getIdForURL($author);
if (!$contact_id) {
@@ -2197,7 +2197,7 @@ class Diaspora
*/
private static function receiveProfile(array $importer, $data)
{
$author = strtolower(notags(XML::unescape($data->author)));
$author = strtolower(Strings::removeTags(XML::unescape($data->author)));
$contact = self::contactByHandle($importer["uid"], $author);
if (!$contact) {
@@ -2574,13 +2574,13 @@ class Diaspora
*/
private static function receiveReshare(array $importer, $data, $xml)
{
$author = notags(XML::unescape($data->author));
$guid = notags(XML::unescape($data->guid));
$created_at = DateTimeFormat::utc(notags(XML::unescape($data->created_at)));
$root_author = notags(XML::unescape($data->root_author));
$root_guid = notags(XML::unescape($data->root_guid));
$author = Strings::removeTags(XML::unescape($data->author));
$guid = Strings::removeTags(XML::unescape($data->guid));
$created_at = DateTimeFormat::utc(Strings::removeTags(XML::unescape($data->created_at)));
$root_author = Strings::removeTags(XML::unescape($data->root_author));
$root_guid = Strings::removeTags(XML::unescape($data->root_guid));
/// @todo handle unprocessed property "provider_display_name"
$public = notags(XML::unescape($data->public));
$public = Strings::removeTags(XML::unescape($data->public));
$contact = self::allowedContactByHandle($importer, $author, false);
if (!$contact) {
@@ -2666,9 +2666,9 @@ class Diaspora
*/
private static function itemRetraction(array $importer, array $contact, $data)
{
$author = notags(XML::unescape($data->author));
$target_guid = notags(XML::unescape($data->target_guid));
$target_type = notags(XML::unescape($data->target_type));
$author = Strings::removeTags(XML::unescape($data->author));
$target_guid = Strings::removeTags(XML::unescape($data->target_guid));
$target_type = Strings::removeTags(XML::unescape($data->target_type));
$person = self::personByHandle($author);
if (!is_array($person)) {
@@ -2730,7 +2730,7 @@ class Diaspora
*/
private static function receiveRetraction(array $importer, $sender, $data)
{
$target_type = notags(XML::unescape($data->target_type));
$target_type = Strings::removeTags(XML::unescape($data->target_type));
$contact = self::contactByHandle($importer["uid"], $sender);
if (!$contact && (in_array($target_type, ["Contact", "Person"]))) {
@@ -2775,12 +2775,12 @@ class Diaspora
*/
private static function receiveStatusMessage(array $importer, SimpleXMLElement $data, $xml)
{
$author = notags(XML::unescape($data->author));
$guid = notags(XML::unescape($data->guid));
$created_at = DateTimeFormat::utc(notags(XML::unescape($data->created_at)));
$public = notags(XML::unescape($data->public));
$author = Strings::removeTags(XML::unescape($data->author));
$guid = Strings::removeTags(XML::unescape($data->guid));
$created_at = DateTimeFormat::utc(Strings::removeTags(XML::unescape($data->created_at)));
$public = Strings::removeTags(XML::unescape($data->public));
$text = XML::unescape($data->text);
$provider_display_name = notags(XML::unescape($data->provider_display_name));
$provider_display_name = Strings::removeTags(XML::unescape($data->provider_display_name));
$contact = self::allowedContactByHandle($importer, $author, false);
if (!$contact) {
@@ -2795,7 +2795,7 @@ class Diaspora
$address = [];
if ($data->location) {
foreach ($data->location->children() as $fieldname => $data) {
$address[$fieldname] = notags(XML::unescape($data));
$address[$fieldname] = Strings::removeTags(XML::unescape($data));
}
}

View File

@@ -44,7 +44,7 @@ class Strings
* @param string $string Input string
* @return string Filtered string
*/
public static function removeTags($string) // notags()
public static function removeTags($string)
{
return str_replace(["<", ">"], ['[', ']'], $string);
}

View File

@@ -18,6 +18,7 @@ use Friendica\Protocol\Email;
use Friendica\Protocol\PortableContact;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
use Friendica\Util\Strings;
use Friendica\Util\XML;
require_once 'include/dba.php';
@@ -474,9 +475,9 @@ class OnePoll
$datarray['title'] .= $subpart->text;
}
}
$datarray['title'] = notags(trim($datarray['title']));
$datarray['title'] = Strings::removeTags(trim($datarray['title']));
//$datarray['title'] = notags(trim($meta->subject));
//$datarray['title'] = Strings::removeTags(trim($meta->subject));
$datarray['created'] = DateTimeFormat::utc($meta->date);
// Is it a reply?