もっともっともっともっとPHP 8.2対応

このコミットが含まれているのは:
守矢諏訪子 2023-08-30 04:08:02 +09:00
コミット ccfa0c90ae
56個のファイルの変更268行の追加236行の削除

ファイルの表示

@ -39,9 +39,7 @@ class DeletenoticeAction extends FormAction
{ {
$this->notice = Notice::getByID($this->trimmed('notice')); $this->notice = Notice::getByID($this->trimmed('notice'));
if ($this->notice->isVerb([ActivityVerb::DELETE]) || if ($this->isAuthorizedToDelete($this->notice)) {
(!$this->scoped->sameAs($this->notice->getProfile()) &&
!$this->scoped->hasRight(Right::DELETEOTHERSNOTICE))) {
// TRANS: Error message displayed when trying to delete a notice that was not made by the current user. // TRANS: Error message displayed when trying to delete a notice that was not made by the current user.
$this->clientError(_('Cannot delete this notice.')); $this->clientError(_('Cannot delete this notice.'));
} }
@ -49,14 +47,21 @@ class DeletenoticeAction extends FormAction
$this->formOpts['notice'] = $this->notice; $this->formOpts['notice'] = $this->notice;
} }
function getInstructions() protected function isAuthorizedToDelete(Notice $notice): bool
{
return $notice->isVerb([ActivityVerb::DELETE]) ||
(!$this->scoped->sameAs($notice->getProfile()) &&
!$this->scoped->hasRight(Right::DELETEOTHERSNOTICE));
}
function getInstructions(): string
{ {
// TRANS: Instructions for deleting a notice. // TRANS: Instructions for deleting a notice.
return _('You are about to permanently delete a notice. ' . return _('You are about to permanently delete a notice. ' .
'Once this is done, it cannot be undone.'); 'Once this is done, it cannot be undone.');
} }
function title() function title(): string
{ {
// TRANS: Page title when deleting a notice. // TRANS: Page title when deleting a notice.
return _('Delete notice'); return _('Delete notice');
@ -65,9 +70,9 @@ class DeletenoticeAction extends FormAction
protected function doPost() protected function doPost()
{ {
if ($this->arg('yes')) { if ($this->arg('yes')) {
if (Event::handle('StartDeleteOwnNotice', array($this->scoped->getUser(), $this->notice))) { if (Event::handle('StartDeleteOwnNotice', [$this->scoped->getUser(), $this->notice])) {
$this->notice->deleteAs($this->scoped); $this->notice->deleteAs($this->scoped);
Event::handle('EndDeleteOwnNotice', array($this->scoped->getUser(), $this->notice)); Event::handle('EndDeleteOwnNotice', [$this->scoped->getUser(), $this->notice]);
} }
} }

ファイルの表示

@ -40,9 +40,9 @@ if (!defined('GNUSOCIAL')) { exit(1); }
*/ */
class DeleteuserAction extends ProfileFormAction class DeleteuserAction extends ProfileFormAction
{ {
var $user = null; protected $user = null;
function prepare(array $args=array()) public function prepare(array $args = []): bool
{ {
if (!parent::prepare($args)) { if (!parent::prepare($args)) {
return false; return false;
@ -85,27 +85,32 @@ class DeleteuserAction extends ProfileFormAction
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($this->arg('no')) { if ($this->arg('no')) {
$this->returnToPrevious(); $this->returnToPrevious();
} elseif ($this->arg('yes')) { return;
}
if ($this->arg('yes')) {
$this->handlePost(); $this->handlePost();
$this->returnToPrevious(); $this->returnToPrevious();
} else { return;
$this->showPage();
} }
$this->showPage();
} }
} }
function showContent() { public function showContent(): void
{
$this->areYouSureForm(); $this->areYouSureForm();
$block = new AccountProfileBlock($this, $this->profile); $block = new AccountProfileBlock($this, $this->profile);
$block->show(); $block->show();
} }
function title() { public function title(): string
{
// TRANS: Title of delete user page. // TRANS: Title of delete user page.
return _m('TITLE','Delete user'); return _m('TITLE','Delete user');
} }
function showNoticeForm() { function showNoticeForm(): void
{
// nop // nop
} }
@ -116,7 +121,7 @@ class DeleteuserAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function areYouSureForm() function areYouSureForm(): void
{ {
$id = $this->profile->id; $id = $this->profile->id;
$this->elementStart('form', array('id' => 'deleteuser-' . $id, $this->elementStart('form', array('id' => 'deleteuser-' . $id,
@ -167,7 +172,7 @@ class DeleteuserAction extends ProfileFormAction
* *
* @return void * @return void
*/ */
function handlePost() function handlePost(): void
{ {
if (Event::handle('StartDeleteUser', array($this, $this->user))) { if (Event::handle('StartDeleteUser', array($this, $this->user))) {
// Mark the account as deleted and shove low-level deletion tasks // Mark the account as deleted and shove low-level deletion tasks

ファイルの表示

@ -163,13 +163,12 @@ class RegisterAction extends Action
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given. // TRANS: Client error displayed when the session token does not match or is not given.
$this->showForm(_('There was a problem with your session token. '. $this->showForm(_('There was a problem with your session token. Try again, please.'));
'Try again, please.'));
return; return;
} }
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$email = $this->trimmed('email'); $email = common_canonical_email($this->trimmed('email'));
$fullname = $this->trimmed('fullname'); $fullname = $this->trimmed('fullname');
$homepage = $this->trimmed('homepage'); $homepage = $this->trimmed('homepage');
$bio = $this->trimmed('bio'); $bio = $this->trimmed('bio');
@ -198,52 +197,54 @@ class RegisterAction extends Action
$this->showForm($e->getMessage()); $this->showForm($e->getMessage());
return; return;
} }
$email = common_canonical_email($email);
if (!$this->boolean('license')) { if (!$this->boolean('license')) {
// TRANS: Form validation error displayed when trying to register without agreeing to the site license. // TRANS: Form validation error displayed when trying to register without agreeing to the site license.
$this->showForm(_('You cannot register if you do not '. $this->showForm(_('You cannot register if you do not agree to the license.'));
'agree to the license.'));
} else if ($email && !Validate::email($email, common_config('email', 'check_domain'))) { } else if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
// TRANS: Form validation error displayed when trying to register without a valid e-mail address. // TRANS: Form validation error displayed when trying to register without a valid e-mail address.
$this->showForm(_('Not a valid email address.')); $this->showForm(_('Not a valid email address.'));
} else if ($this->emailExists($email)) { } else if ($this->emailExists($email)) {
// TRANS: Form validation error displayed when trying to register with an already registered e-mail address. // TRANS: Form validation error displayed when trying to register with an already registered e-mail address.
$this->showForm(_('Email address already exists.')); $this->showForm(_('Email address already exists.'));
} else if (!is_null($homepage) && (strlen($homepage) > 0) && } else if (!is_null($homepage) && (strlen($homepage) > 0) && !common_valid_http_url($homepage)) {
!common_valid_http_url($homepage)) {
// TRANS: Form validation error displayed when trying to register with an invalid homepage URL. // TRANS: Form validation error displayed when trying to register with an invalid homepage URL.
$this->showForm(_('Homepage is not a valid URL.')); $this->showForm(_('Homepage is not a valid URL.'));
} else if (Profile::bioTooLong($bio)) { } else if (Profile::bioTooLong($bio)) {
// TRANS: Form validation error on registration page when providing too long a bio text. // TRANS: Form validation error on registration page when providing too long a bio text.
// TRANS: %d is the maximum number of characters for bio; used for plural. // TRANS: %d is the maximum number of characters for bio; used for plural.
$this->showForm(sprintf(_m('Bio is too long (maximum %d character).', $this->showForm(sprintf(_m('Bio is too long (maximum %d character).',
'Bio is too long (maximum %d characters).', 'Bio is too long (maximum %d characters).',
Profile::maxBio()), Profile::maxBio()),
Profile::maxBio())); Profile::maxBio()));
} else if (strlen($password) < 6) { } else if (strlen($password) < 6) {
// TRANS: Form validation error displayed when trying to register with too short a password. // TRANS: Form validation error displayed when trying to register with too short a password.
$this->showForm(_('Password must be 6 or more characters.')); $this->showForm(_('Password must be 6 or more characters.'));
} else if ($password != $confirm) { } else if ($password != $confirm) {
// TRANS: Form validation error displayed when trying to register with non-matching passwords. // TRANS: Form validation error displayed when trying to register with non-matching passwords.
$this->showForm(_('Passwords do not match.')); $this->showForm(_('Passwords do not match.'));
} else { } else {
try { try {
$user = User::register(array('nickname' => $nickname, $user = User::register([
'password' => $password, 'nickname' => $nickname,
'email' => $email, 'password' => $password,
'fullname' => $fullname, 'email' => $email,
'homepage' => $homepage, 'fullname' => $this->trimmed('fullname'),
'bio' => $bio, 'homepage' => $this->trimmed('homepage'),
'location' => $location, 'bio' => $this->trimmed('bio'),
'code' => $code)); 'location' => $this->trimmed('location'),
'code' => $code
]);
// success! // success!
if (!common_set_user($user)) { if (!common_set_user($user)) {
// TRANS: Server error displayed when saving fails during user registration. // TRANS: Server error displayed when saving fails during user registration.
$this->serverError(_('Error setting user.')); $this->serverError(_('Error setting user.'));
} }
// this is a real login // this is a real login
common_real_login(true); common_real_login(true);
if ($this->boolean('rememberme')) { if ($this->boolean('rememberme')) {
common_debug('Adding rememberme cookie for ' . $nickname); common_debug('Adding rememberme cookie for ' . $nickname);
common_rememberme($user); common_rememberme($user);
@ -251,9 +252,7 @@ class RegisterAction extends Action
// Re-init language env in case it changed (not yet, but soon) // Re-init language env in case it changed (not yet, but soon)
common_init_language(); common_init_language();
Event::handle('EndRegistrationTry', [$this]);
Event::handle('EndRegistrationTry', array($this));
$this->showSuccess(); $this->showSuccess();
} catch (Exception $e) { } catch (Exception $e) {
// TRANS: Form validation error displayed when trying to register with an invalid username or password. // TRANS: Form validation error displayed when trying to register with an invalid username or password.

ファイルの表示

@ -31,6 +31,7 @@ defined('GNUSOCIAL') || die();
class File extends Managed_DataObject class File extends Managed_DataObject
{ {
public $is_mariadb; public $is_mariadb;
public $total;
public $__table = 'file'; // table name public $__table = 'file'; // table name
public $id; // int(4) primary_key not_null public $id; // int(4) primary_key not_null
@ -426,7 +427,7 @@ class File extends Managed_DataObject
*/ */
public static function validFilename($filename) public static function validFilename($filename)
{ {
return preg_match('/^[A-Za-z0-9._-]+$/', $filename); return preg_match('/^[A-Za-z0-9._-]+$/', $filename ?? "");
} }
/** /**

ファイルの表示

@ -100,7 +100,7 @@ class File_thumbnail extends Managed_DataObject
$file = File::getById($file->getID()); $file = File::getById($file->getID());
} }
if (file_exists($imgPath)) { if (file_exists($imgPath ?? "")) {
$image = new ImageFile($imgPath, $file->getID(), null, $file->getUrl(false)); $image = new ImageFile($imgPath, $file->getID(), null, $file->getUrl(false));
} else { } else {
try { try {

ファイルの表示

@ -802,7 +802,7 @@ class Notice extends Managed_DataObject
// Get ActivityObject properties // Get ActivityObject properties
$actobj = null; $actobj = null;
if ($act->objects[0]->id !== null) { if ($act->id !== null) {
// implied object // implied object
$options['uri'] = $act->id ?? ""; $options['uri'] = $act->id ?? "";
$options['url'] = $act->link ?? ""; $options['url'] = $act->link ?? "";
@ -810,7 +810,7 @@ class Notice extends Managed_DataObject
$options['self'] = $act->selfLink; $options['self'] = $act->selfLink;
} }
} else { } else {
$actobj = count($act->objects)===1 ? $act->objects[0] : null; $actobj = count($act->objects) === 1 ? $act->objects[0] : null;
if ($actobj !== null && !empty($actobj->id)) { if ($actobj !== null && !empty($actobj->id)) {
$options['uri'] = $actobj->id ?? ""; $options['uri'] = $actobj->id ?? "";
if ($actobj->link !== null) { if ($actobj->link !== null) {
@ -889,7 +889,7 @@ class Notice extends Managed_DataObject
// we use mb_strlen because it _might_ be that the content is just the string "0"... // we use mb_strlen because it _might_ be that the content is just the string "0"...
$content = $act->content ?? $act->summary; $content = $act->content ?? $act->summary;
if (mb_strlen($content) === 0 && !is_null($actobj)) { if (mb_strlen($content ?? "") === 0 && $actobj !== null) {
$content = $actobj->content ?? $actobj->summary; $content = $actobj->content ?? $actobj->summary;
} }

ファイルの表示

@ -265,7 +265,7 @@ class Profile extends Managed_DataObject
} }
} }
if (mb_strlen($this->getFullname()) > 0) { if (mb_strlen($this->getFullname() ?? "") > 0) {
// TRANS: The "fancy name": Full name of a profile or group (%1$s) followed by some URI (%2$s) in parentheses. // TRANS: The "fancy name": Full name of a profile or group (%1$s) followed by some URI (%2$s) in parentheses.
return sprintf(_m('FANCYNAME', '%1$s (%2$s)'), $this->getFullname(), $uri); return sprintf(_m('FANCYNAME', '%1$s (%2$s)'), $this->getFullname(), $uri);
} else { } else {

ファイルの表示

@ -62,63 +62,63 @@ class User extends Managed_DataObject
public static function schemaDef() public static function schemaDef()
{ {
return array( return [
'description' => 'local users', 'description' => 'local users',
'fields' => array( 'fields' => [
'id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), 'id' => ['type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'],
'nickname' => array('type' => 'varchar', 'length' => 64, 'description' => 'nickname or username, duped in profile'), 'nickname' => ['type' => 'varchar', 'length' => 64, 'description' => 'nickname or username, duped in profile'],
'password' => array('type' => 'text', 'description' => 'salted password, can be null for OpenID users'), 'password' => ['type' => 'text', 'description' => 'salted password, can be null for OpenID users'],
'email' => array('type' => 'varchar', 'length' => 191, 'description' => 'email address for password recovery etc.'), 'email' => ['type' => 'varchar', 'length' => 191, 'description' => 'email address for password recovery etc.'],
'incomingemail' => array('type' => 'varchar', 'length' => 191, 'description' => 'email address for post-by-email'), 'incomingemail' => ['type' => 'varchar', 'length' => 191, 'description' => 'email address for post-by-email'],
'emailnotifysub' => array('type' => 'bool', 'default' => true, 'description' => 'Notify by email of subscriptions'), 'emailnotifysub' => ['type' => 'bool', 'default' => true, 'description' => 'Notify by email of subscriptions'],
'emailnotifyfav' => array('type' => 'int', 'size' => 'tiny', 'default' => null, 'description' => 'Notify by email of favorites'), 'emailnotifyfav' => ['type' => 'int', 'size' => 'tiny', 'default' => null, 'description' => 'Notify by email of favorites'],
'emailnotifynudge' => array('type' => 'bool', 'default' => true, 'description' => 'Notify by email of nudges'), 'emailnotifynudge' => ['type' => 'bool', 'default' => true, 'description' => 'Notify by email of nudges'],
'emailnotifymsg' => array('type' => 'bool', 'default' => true, 'description' => 'Notify by email of direct messages'), 'emailnotifymsg' => ['type' => 'bool', 'default' => true, 'description' => 'Notify by email of direct messages'],
'emailnotifyattn' => array('type' => 'bool', 'default' => true, 'description' => 'Notify by email of @-replies'), 'emailnotifyattn' => ['type' => 'bool', 'default' => true, 'description' => 'Notify by email of @-replies'],
'language' => array('type' => 'varchar', 'length' => 50, 'description' => 'preferred language'), 'language' => ['type' => 'varchar', 'length' => 50, 'description' => 'preferred language'],
'timezone' => array('type' => 'varchar', 'length' => 50, 'description' => 'timezone'), 'timezone' => ['type' => 'varchar', 'length' => 50, 'description' => 'timezone'],
'emailpost' => array('type' => 'bool', 'default' => true, 'description' => 'Post by email'), 'emailpost' => ['type' => 'bool', 'default' => true, 'description' => 'Post by email'],
'sms' => array('type' => 'varchar', 'length' => 64, 'description' => 'sms phone number'), 'sms' => ['type' => 'varchar', 'length' => 64, 'description' => 'sms phone number'],
'carrier' => array('type' => 'int', 'description' => 'foreign key to sms_carrier'), 'carrier' => ['type' => 'int', 'description' => 'foreign key to sms_carrier'],
'smsnotify' => array('type' => 'bool', 'default' => false, 'description' => 'whether to send notices to SMS'), 'smsnotify' => ['type' => 'bool', 'default' => false, 'description' => 'whether to send notices to SMS'],
'smsreplies' => array('type' => 'bool', 'default' => false, 'description' => 'whether to send notices to SMS on replies'), 'smsreplies' => ['type' => 'bool', 'default' => false, 'description' => 'whether to send notices to SMS on replies'],
'smsemail' => array('type' => 'varchar', 'length' => 191, 'description' => 'built from sms and carrier'), 'smsemail' => ['type' => 'varchar', 'length' => 191, 'description' => 'built from sms and carrier'],
'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier, usually a tag URI'), 'uri' => ['type' => 'varchar', 'length' => 191, 'description' => 'universally unique identifier, usually a tag URI'],
'autosubscribe' => array('type' => 'bool', 'default' => false, 'description' => 'automatically subscribe to users who subscribe to us'), 'autosubscribe' => ['type' => 'bool', 'default' => false, 'description' => 'automatically subscribe to users who subscribe to us'],
'subscribe_policy' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'), 'subscribe_policy' => ['type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => '0 = anybody can subscribe; 1 = require approval'],
'urlshorteningservice' => array('type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'), 'urlshorteningservice' => ['type' => 'varchar', 'length' => 50, 'default' => 'internal', 'description' => 'service to use for auto-shortening URLs'],
'private_stream' => array('type' => 'bool', 'default' => false, 'description' => 'whether to limit all notices to followers only'), 'private_stream' => ['type' => 'bool', 'default' => false, 'description' => 'whether to limit all notices to followers only'],
'created' => array('type' => 'datetime', 'description' => 'date this record was created'), 'created' => ['type' => 'datetime', 'description' => 'date this record was created'],
'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
), ],
'primary key' => array('id'), 'primary key' => ['id'],
'unique keys' => array( 'unique keys' => [
'user_nickname_key' => array('nickname'), 'user_nickname_key' => ['nickname'],
'user_email_key' => array('email'), 'user_email_key' => ['email'],
'user_incomingemail_key' => array('incomingemail'), 'user_incomingemail_key' => ['incomingemail'],
'user_sms_key' => array('sms'), 'user_sms_key' => ['sms'],
'user_uri_key' => array('uri'), 'user_uri_key' => ['uri'],
), ],
'foreign keys' => array( 'foreign keys' => [
'user_id_fkey' => array('profile', array('id' => 'id')), 'user_id_fkey' => ['profile', ['id' => 'id']],
'user_carrier_fkey' => array('sms_carrier', array('carrier' => 'id')), 'user_carrier_fkey' => ['sms_carrier', ['carrier' => 'id']],
), ],
'indexes' => array( 'indexes' => [
'user_carrier_idx' => array('carrier'), 'user_carrier_idx' => ['carrier'],
'user_created_id_idx' => array('created', 'id'), 'user_created_id_idx' => ['created', 'id'],
'user_smsemail_idx' => array('smsemail'), 'user_smsemail_idx' => ['smsemail'],
), ],
); ];
} }
protected $_profile = array(); protected $_profile = [];
/** /**
* @return Profile * @return Profile
* *
* @throws UserNoProfileException if user has no profile * @throws UserNoProfileException if user has no profile
*/ */
public function getProfile() public function getProfile(): object
{ {
if (!isset($this->_profile[$this->id])) { if (!isset($this->_profile[$this->id])) {
$profile = Profile::getKV('id', $this->id); $profile = Profile::getKV('id', $this->id);
@ -135,12 +135,12 @@ class User extends Managed_DataObject
return $this->getProfile()->sameAs($other); return $this->getProfile()->sameAs($other);
} }
public function getUri() public function getUri(): string
{ {
return $this->uri; return $this->uri;
} }
public function getNickname() public function getNickname(): string
{ {
return $this->getProfile()->getNickname(); return $this->getProfile()->getNickname();
} }
@ -149,7 +149,7 @@ class User extends Managed_DataObject
{ {
$user = User::getKV('nickname', $nickname); $user = User::getKV('nickname', $nickname);
if (!$user instanceof User) { if (!$user instanceof User) {
throw new NoSuchUserException(array('nickname' => $nickname)); throw new NoSuchUserException(['nickname' => $nickname]);
} }
return $user; return $user;
@ -277,7 +277,7 @@ class User extends Managed_DataObject
$user->created = common_sql_now(); $user->created = common_sql_now();
if (Event::handle('StartUserRegister', array($profile))) { if (Event::handle('StartUserRegister', [$profile])) {
$profile->query('START TRANSACTION'); $profile->query('START TRANSACTION');
$id = $profile->insert(); $id = $profile->insert();
@ -416,7 +416,7 @@ class User extends Managed_DataObject
} }
} }
Event::handle('EndUserRegister', array($profile)); Event::handle('EndUserRegister', [$profile]);
} }
if (!$user instanceof User || empty($user->id)) { if (!$user instanceof User || empty($user->id)) {
@ -630,14 +630,14 @@ class User extends Managed_DataObject
common_log(LOG_INFO, "User {$this->nickname} has no profile; continuing deletion."); common_log(LOG_INFO, "User {$this->nickname} has no profile; continuing deletion.");
} }
$related = array( $related = [
'Confirm_address', 'Confirm_address',
'Remember_me', 'Remember_me',
'Foreign_link', 'Foreign_link',
'Invitation', 'Invitation',
); ];
Event::handle('UserDeleteRelated', array($this, &$related)); Event::handle('UserDeleteRelated', [$this, &$related]);
foreach ($related as $cls) { foreach ($related as $cls) {
$inst = new $cls(); $inst = new $cls();
@ -875,7 +875,7 @@ class User extends Managed_DataObject
public function __sleep() public function __sleep()
{ {
$vars = parent::__sleep(); $vars = parent::__sleep();
$skip = array('_profile'); $skip = ['_profile'];
return array_diff($vars, $skip); return array_diff($vars, $skip);
} }

ファイルの表示

@ -385,7 +385,7 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
return true; return true;
} }
$lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding') ?? "")
|| null !== $response->getHeader('content-length') || null !== $response->getHeader('content-length')
// no body possible for such responses, see also request #17031 // no body possible for such responses, see also request #17031
|| HTTP_Request2::METHOD_HEAD == $this->request->getMethod() || HTTP_Request2::METHOD_HEAD == $this->request->getMethod()
@ -1135,4 +1135,4 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
} }
} }
?> ?>

ファイルの表示

@ -53,6 +53,8 @@ require_once 'HTTP/Request2/Exception.php';
*/ */
class HTTP_Request2_Response class HTTP_Request2_Response
{ {
public $redirUrls;
/** /**
* HTTP protocol version (e.g. 1.0, 1.1) * HTTP protocol version (e.g. 1.0, 1.1)
* @var string * @var string
@ -677,4 +679,4 @@ class HTTP_Request2_Response
return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data); return (0 == $header[1] % 31)? gzuncompress($data): gzinflate($data);
} }
} }
?> ?>

ファイルの表示

@ -195,11 +195,13 @@ class HTTP_Request2_SocketWrapper
$info = stream_get_meta_data($this->socket); $info = stream_get_meta_data($this->socket);
$old_blocking = (bool)$info['blocked']; $old_blocking = (bool)$info['blocked'];
stream_set_blocking($this->socket, false); stream_set_blocking($this->socket, false);
$r = array($this->socket); $r = [$this->socket];
$w = array(); $w = [];
$e = array(); $e = [];
if (stream_select($r, $w, $e, $timeout)) { if (stream_select($r, $w, $e, $timeout)) {
$line .= @fgets($this->socket, $bufferSize); $line .= @fgets($this->socket, $bufferSize);
} else {
echo "stream_select失敗: " . error_get_last()['message'];
} }
stream_set_blocking($this->socket, $old_blocking); stream_set_blocking($this->socket, $old_blocking);

ファイルの表示

@ -14,7 +14,7 @@ class IDNATest extends PHPUnit_Framework_TestCase
public static function unichr($chr) public static function unichr($chr)
{ {
return mb_convert_encoding('&#' . intval($chr) . ';', 'UTF-8', 'HTML-ENTITIES'); return htmlspecialchars('&#' . intval($chr) . ';', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
} }
private function hexarray2string($arr) private function hexarray2string($arr)

ファイルの表示

@ -175,10 +175,8 @@ function _get_codeset($domain=null) {
*/ */
function _encode($text) { function _encode($text) {
$target_encoding = _get_codeset(); $target_encoding = _get_codeset();
if (function_exists("mb_detect_encoding")) { if ($source_encoding != $target_encoding) {
$source_encoding = mb_detect_encoding($text); $text = htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
if ($source_encoding != $target_encoding)
$text = mb_convert_encoding($text, $target_encoding, $source_encoding);
} }
return $text; return $text;
} }

ファイルの表示

@ -51,6 +51,10 @@ if (!defined('GNUSOCIAL')) { exit(1); }
*/ */
class GNUsocial_HTTPResponse extends HTTP_Request2_Response class GNUsocial_HTTPResponse extends HTTP_Request2_Response
{ {
public $redirUrls;
public $url;
public $redirectCount;
function __construct(HTTP_Request2_Response $response, $url, $redirects=0) function __construct(HTTP_Request2_Response $response, $url, $redirects=0)
{ {
foreach (get_object_vars($response) as $key => $val) { foreach (get_object_vars($response) as $key => $val) {

ファイルの表示

@ -2080,7 +2080,7 @@ function common_get_mime_media($type)
// Get only the mimetype and not additional info (separated from bare mime with semi-colon) // Get only the mimetype and not additional info (separated from bare mime with semi-colon)
function common_bare_mime($mimetype) function common_bare_mime($mimetype)
{ {
$mimetype = mb_strtolower($mimetype); $mimetype = mb_strtolower($mimetype ?? "");
if (($semicolon = mb_strpos($mimetype, ';')) !== false) { if (($semicolon = mb_strpos($mimetype, ';')) !== false) {
$mimetype = mb_substr($mimetype, 0, $semicolon); $mimetype = mb_substr($mimetype, 0, $semicolon);
} }

ファイルの表示

@ -25,9 +25,9 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("classes/Activitypub_profile.php"); include("../plugins/ActivityPub/classes/Activitypub_profile.php");
include("classes/Activitypub_rsa.php"); include("../plugins/ActivityPub/classes/Activitypub_rsa.php");
include("classes/Activitypub_pending_follow_requests.php"); include("../plugins/ActivityPub/classes/Activitypub_pending_follow_requests.php");
// Import plugin libs // Import plugin libs
foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . '*.php') as $filename) { foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . '*.php') as $filename) {

ファイルの表示

@ -55,7 +55,7 @@ class Activitypub_attachment
]; ];
// Image // Image
if (substr($res["mediaType"], 0, 5) == "image") { if (substr($res["mediaType"], "", 5) == "image") {
$res["meta"]= [ $res["meta"]= [
'width' => $attachment->width, 'width' => $attachment->width,
'height' => $attachment->height 'height' => $attachment->height

ファイルの表示

@ -85,7 +85,7 @@ class Activitypub_notice
'id' => self::getUri($notice), 'id' => self::getUri($notice),
'type' => 'Delete', 'type' => 'Delete',
// XXX: A bit of ugly code here // XXX: A bit of ugly code here
'object' => array_merge(Activitypub_tombstone::tombstone_to_array((int)substr(explode(':', $notice->getUri())[2], 9)), ['deleted' => str_replace(' ', 'T', $notice->getCreated()) . 'Z']), 'object' => array_merge(Activitypub_tombstone::tombstone_to_array((int)substr(explode(':', $notice->getUri())[2] ?? "", 9)), ['deleted' => str_replace(' ', 'T', $notice->getCreated()) . 'Z']),
'url' => $notice->getUrl(), 'url' => $notice->getUrl(),
'actor' => $profile->getUri(), 'actor' => $profile->getUri(),
'to' => $to, 'to' => $to,

ファイルの表示

@ -33,7 +33,7 @@ if (!defined('STATUSNET')) {
// your code file can't be executed directly from the web. // your code file can't be executed directly from the web.
exit(1); exit(1);
} }
include("classes/Spam_score.php"); include("../plugins/ActivitySpam/classes/Spam_score.php");
/** /**
* Check new notices with activity spam service. * Check new notices with activity spam service.

ファイルの表示

@ -33,7 +33,7 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("classes/Fave_tally.php"); include("../plugins/AnonymousFave/classes/Fave_tally.php");
define('ANONYMOUS_FAVE_PLUGIN_VERSION', '0.1.0'); define('ANONYMOUS_FAVE_PLUGIN_VERSION', '0.1.0');

ファイルの表示

@ -28,8 +28,8 @@
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) { exit(1); }
include("classes/Nickname_blacklist.php"); include("../plugins/Blacklist/classes/Nickname_blacklist.php");
include("classes/Homepage_blacklist.php"); include("../plugins/Blacklist/classes/Homepage_blacklist.php");
/** /**
* Plugin to prevent use of nicknames or URLs on a blacklist * Plugin to prevent use of nicknames or URLs on a blacklist

ファイルの表示

@ -29,10 +29,10 @@
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) { exit(1); }
include("classes/Bookmark.php"); include("../plugins/Bookmark/classes/Bookmark.php");
include("lib/bookmarksnoticestream.php"); include("../plugins/Bookmark/lib/bookmarksnoticestream.php");
include("lib/deliciousbackupimporter.php"); include("../plugins/Bookmark/lib/deliciousbackupimporter.php");
include("lib/deliciousbookmarkimporter.php"); include("../plugins/Bookmark/lib/deliciousbookmarkimporter.php");
/** /**
* Bookmark plugin main class * Bookmark plugin main class

ファイルの表示

@ -355,7 +355,6 @@ class Bookmark extends Managed_DataObject
foreach ($tags as $term) { foreach ($tags as $term) {
$catEl = new AtomCategory(); $catEl = new AtomCategory();
$catEl->term = $term; $catEl->term = $term;
$activity->categories[] = $catEl;
} }
$options = array_merge([ $options = array_merge([

ファイルの表示

@ -26,7 +26,7 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("lib/conversationtree.php"); include("../plugins/ConversationTree/lib/conversationtree.php");
class ConversationTreePlugin extends Plugin class ConversationTreePlugin extends Plugin
{ {

ファイルの表示

@ -11,7 +11,7 @@
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) { exit(1); }
include("lib/cronish.php"); include("../plugins/Cronish/lib/cronish.php");
class CronishPlugin extends Plugin { class CronishPlugin extends Plugin {
const PLUGIN_VERSION = '2.0.0'; const PLUGIN_VERSION = '2.0.0';

ファイルの表示

@ -24,7 +24,7 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("classes/DBQueueManager.php"); include("../plugins/DBQueue/classes/DBQueueManager.php");
class DBQueuePlugin extends Plugin class DBQueuePlugin extends Plugin
{ {

ファイルの表示

@ -25,7 +25,7 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("classes/Message.php"); include("../plugins/DirectMessage/classes/Message.php");
// require needed abstractions first // require needed abstractions first
require_once __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'messagelist.php'; require_once __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'messagelist.php';

ファイルの表示

@ -31,9 +31,8 @@
if (!defined('STATUSNET')) { if (!defined('STATUSNET')) {
exit(1); exit(1);
} }
include("lib/alphanav.php"); include("../plugins/Directory/lib/alphanav.php");
include("lib/sortablegrouplist.php"); include("../plugins/Directory/lib/sortablegrouplist.php");
//include("lib/sortablesubscriptionlist.php");
/** /**
* Directory plugin main class * Directory plugin main class

ファイルの表示

@ -33,8 +33,8 @@ if (!defined('STATUSNET')) {
// your code file can't be executed directly from the web. // your code file can't be executed directly from the web.
exit(1); exit(1);
} }
include("lib/domainstatusnetworkinstaller.php"); include("../plugins/DomainStatusNetwork/lib/domainstatusnetworkinstaller.php");
include("lib/freeemail.php"); include("../plugins/DomainStatusNetwork/lib/freeemail.php");
$_dir = dirname(__FILE__); $_dir = dirname(__FILE__);

ファイルの表示

@ -33,9 +33,9 @@ if (!defined('STATUSNET')) {
// your code file can't be executed directly from the web. // your code file can't be executed directly from the web.
exit(1); exit(1);
} }
include("lib/siteconfirmreminderhandler.php"); include("../plugins/EmailReminder/lib/siteconfirmreminderhandler.php");
include("lib/userconfirmregreminderhandler.php"); include("../plugins/EmailReminder/lib/userconfirmregreminderhandler.php");
include("lib/userinvitereminderhandler.php"); include("../plugins/EmailReminder/lib/userinvitereminderhandler.php");
/** /**
* Email reminder plugin * Email reminder plugin

ファイルの表示

@ -30,7 +30,8 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("classes/File_embed.php"); include("../plugins/Embed/classes/File_embed.php");
include("../plugins/Embed/lib/embedhelper.php");
use Embed\Embed; use Embed\Embed;

ファイルの表示

@ -29,10 +29,10 @@
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) { exit(1); }
include("classes/Happening.php"); include("../plugins/Event/classes/Happening.php");
include("classes/RSVP.php"); include("../plugins/Event/classes/RSVP.php");
include("lib/eventsnoticestream.php"); include("../plugins/Event/lib/eventsnoticestream.php");
include("lib/eventtimelist.php"); include("../plugins/Event/lib/eventtimelist.php");
/** /**
* Event plugin * Event plugin

ファイルの表示

@ -133,31 +133,31 @@ class NeweventAction extends FormAction
$actobj->type = Happening::OBJECT_TYPE; $actobj->type = Happening::OBJECT_TYPE;
$actobj->title = $title; $actobj->title = $title;
$actobj->summary = $description; $actobj->summary = $description;
$actobj->extra[] = array('dtstart', $actobj->extra[] = ['dtstart',
array('xmlns' => 'urn:ietf:params:xml:ns:xcal'), ['xmlns' => 'urn:ietf:params:xml:ns:xcal'],
common_date_iso8601($start_str)); common_date_iso8601($start_str)];
$actobj->extra[] = array('dtend', $actobj->extra[] = ['dtend',
array('xmlns' => 'urn:ietf:params:xml:ns:xcal'), ['xmlns' => 'urn:ietf:params:xml:ns:xcal'],
common_date_iso8601($end_str)); common_date_iso8601($end_str)];
$actobj->extra[] = array('location', $actobj->extra[] = ['location',
array('xmlns' => 'urn:ietf:params:xml:ns:xcal'), ['xmlns' => 'urn:ietf:params:xml:ns:xcal'],
$location); $location];
$actobj->extra[] = array('url', $actobj->extra[] = ['url',
array('xmlns' => 'urn:ietf:params:xml:ns:xcal'), ['xmlns' => 'urn:ietf:params:xml:ns:xcal'],
$url); $url];
/* We don't use these ourselves, but we add them to be nice RSS/XML citizens */ /* We don't use these ourselves, but we add them to be nice RSS/XML citizens */
$actobj->extra[] = array('startdate', $actobj->extra[] = ['startdate',
array('xmlns' => 'http://purl.org/rss/1.0/plugins/event/'), ['xmlns' => 'http://purl.org/rss/1.0/plugins/event/'],
common_date_iso8601($start_str)); common_date_iso8601($start_str)];
$actobj->extra[] = array('enddate', $actobj->extra[] = ['enddate',
array('xmlns' => 'http://purl.org/rss/1.0/plugins/event/'), ['xmlns' => 'http://purl.org/rss/1.0/plugins/event/'],
common_date_iso8601($end_str)); common_date_iso8601($end_str)];
$actobj->extra[] = array('location', $actobj->extra[] = ['location',
array('xmlns' => 'http://purl.org/rss/1.0/plugins/event/'), ['xmlns' => 'http://purl.org/rss/1.0/plugins/event/'],
$location); $location];
$act->objects = array($actobj); $act->objects = [$actobj];
$stored = Notice::saveActivity($act, $this->scoped, $options); $stored = Notice::saveActivity($act, $this->scoped, $options);

ファイルの表示

@ -44,7 +44,9 @@ class RsvpAction extends FormAction
{ {
protected $form = 'RSVP'; protected $form = 'RSVP';
public $rsvp = "";
protected $event = null; protected $event = null;
public $args;
function title() function title()
{ {
@ -54,11 +56,21 @@ class RsvpAction extends FormAction
protected function doPreparation() protected function doPreparation()
{ {
if (isset($this->args["yes"])) {
$this->rsvp = "yes;
} else if (isset($this->args["maybe"])) {
$this->rsvp = "maybe";
} else if (isset($this->args["cancel"])) {
$this->rsvp = "cancel";
} else {
$this->rsvp = "no";
}
if ($this->trimmed('notice')) { if ($this->trimmed('notice')) {
$stored = Notice::getByID($this->trimmed('notice')); $stored = Notice::getByID($this->trimmed('notice'));
$this->event = Happening::fromStored($stored); $this->event = Happening::fromStored($stored);
} else { } else {
$this->event = Happening::getByKeys(['uri'=>$this->trimmed('event')]); $this->event = Happening::getByKeys(['uri' => $this->trimmed('event')]);
} }
$this->formOpts['event'] = $this->event; $this->formOpts['event'] = $this->event;
@ -66,7 +78,7 @@ class RsvpAction extends FormAction
protected function doPost() protected function doPost()
{ {
if ($this->trimmed('rsvp') === 'cancel') { if ($this->rsvp === 'cancel') {
$rsvp = RSVP::byEventAndActor($this->event, $this->scoped); $rsvp = RSVP::byEventAndActor($this->event, $this->scoped);
try { try {
$notice = $rsvp->getStored(); $notice = $rsvp->getStored();
@ -81,7 +93,7 @@ class RsvpAction extends FormAction
return _m('Cancelled RSVP'); return _m('Cancelled RSVP');
} }
$verb = RSVP::verbFor(strtolower($this->trimmed('rsvp'))); $verb = RSVP::verbFor(strtolower($this->rsvp));
$options = array('source' => 'web'); $options = array('source' => 'web');
$act = new Activity(); $act = new Activity();

ファイルの表示

@ -61,6 +61,7 @@ class TimelistAction extends Action {
parent::handle(); parent::handle();
if (!common_logged_in()) { if (!common_logged_in()) {
error_log("penis1");
// TRANS: Error message displayed when trying to perform an action that requires a logged in user. // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_m('Not logged in.')); $this->clientError(_m('Not logged in.'));
} }
@ -68,6 +69,7 @@ class TimelistAction extends Action {
if (!empty($this->start)) { if (!empty($this->start)) {
$times = EventTimeList::getTimes($this->start, $this->duration); $times = EventTimeList::getTimes($this->start, $this->duration);
} else { } else {
error_log("penis2");
// TRANS: Client error when submitting a form with unexpected information. // TRANS: Client error when submitting a form with unexpected information.
$this->clientError(_m('Unexpected form submission.')); $this->clientError(_m('Unexpected form submission.'));
} }
@ -76,6 +78,7 @@ class TimelistAction extends Action {
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
print json_encode($times); print json_encode($times);
} else { } else {
error_log("penis3");
// TRANS: Client error displayed when using an action in a non-AJAX way. // TRANS: Client error displayed when using an action in a non-AJAX way.
$this->clientError(_m('This action is AJAX only.')); $this->clientError(_m('This action is AJAX only.'));
} }
@ -88,7 +91,9 @@ class TimelistAction extends Action {
* @param string $msg error message * @param string $msg error message
* @param int $code error code * @param int $code error code
*/ */
function clientError($msg, $code = 400) { function clientError($msg, $code = 400, ?string $format = null): void
{
error_log("penis");
if ($this->boolean('ajax')) { if ($this->boolean('ajax')) {
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
print json_encode( print json_encode(

ファイルの表示

@ -26,7 +26,7 @@
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) { exit(1); }
include("lib/discovery.php"); include("../plugins/LRDD/lib/discovery.php");
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/extlib/'); set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/extlib/');

ファイルの表示

@ -25,7 +25,7 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("classes/Usage_stats.php"); include("../plugins/Nodeinfo/classes/Usage_stats.php");
/** /**
* Controls cache and routes * Controls cache and routes

ファイルの表示

@ -26,10 +26,10 @@
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("classes/Ostatus_profile.php"); include("../plugins/OStatus/classes/Ostatus_profile.php");
include("classes/FeedSub.php"); include("../plugins/OStatus/classes/FeedSub.php");
include("classes/HubSub.php"); include("../plugins/OStatus/classes/HubSub.php");
include("classes/Magicsig.php"); include("../plugins/OStatus/classes/Magicsig.php");
require_once __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'util.php'; require_once __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'util.php';

ファイルの表示

@ -27,6 +27,9 @@ defined('GNUSOCIAL') || die();
*/ */
class OStatusQueueHandler extends QueueHandler class OStatusQueueHandler extends QueueHandler
{ {
public $notice;
public $user;
// If we have more than this many subscribing sites on a single feed, // If we have more than this many subscribing sites on a single feed,
// break up the WebSub distribution into smaller batches which will be // break up the WebSub distribution into smaller batches which will be
// rolled into the queue progressively. This reduces disruption to // rolled into the queue progressively. This reduces disruption to

ファイルの表示

@ -30,9 +30,9 @@
if (!defined('STATUSNET')) { if (!defined('STATUSNET')) {
exit(1); exit(1);
} }
include("classes/User_openid.php"); include("../plugins/OpenID/classes/User_openid.php");
include("classes/User_openid_trustroot.php"); include("../plugins/OpenID/classes/User_openid_trustroot.php");
include("classes/User_openid_prefs.php"); include("../plugins/OpenID/classes/User_openid_prefs.php");
/** /**
* Plugin for OpenID authentication and identity * Plugin for OpenID authentication and identity

ファイルの表示

@ -1,6 +1,6 @@
<?php <?php
include("lib/opportunisticqueuemanager.php"); include("../plugins/OpportunisticQM/lib/opportunisticqueuemanager.php");
class OpportunisticQMPlugin extends Plugin { class OpportunisticQMPlugin extends Plugin {
const PLUGIN_VERSION = '3.0.0'; const PLUGIN_VERSION = '3.0.0';

ファイルの表示

@ -31,9 +31,9 @@
if (!defined('STATUSNET')) { if (!defined('STATUSNET')) {
exit(1); exit(1);
} }
include("classes/Poll.php"); include("../plugins/Poll/classes/Poll.php");
include("classes/Poll_response.php"); include("../plugins/Poll/classes/Poll_response.php");
include("classes/User_poll_prefs.php"); include("../plugins/Poll/classes/User_poll_prefs.php");
/** /**
* Poll plugin main class * Poll plugin main class

ファイルの表示

@ -36,6 +36,8 @@ defined('GNUSOCIAL') || die();
*/ */
class Poll_response extends Managed_DataObject class Poll_response extends Managed_DataObject
{ {
public $votes;
public $__table = 'poll_response'; // table name public $__table = 'poll_response'; // table name
public $id; // char(36) primary key not null -> UUID public $id; // char(36) primary key not null -> UUID
public $uri; // varchar(191) not 255 because utf8mb4 takes more space public $uri; // varchar(191) not 255 because utf8mb4 takes more space

ファイルの表示

@ -25,7 +25,7 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("classes/Registration_ip.php"); include("../plugins/RegisterThrottle/classes/Registration_ip.php");
/** /**
* Throttle registration by IP address * Throttle registration by IP address

ファイルの表示

@ -31,7 +31,7 @@
if (!defined('STATUSNET')) { if (!defined('STATUSNET')) {
exit(1); exit(1);
} }
include("classes/TagSub.php"); include("../plugins/TagSub/classes/TagSub.php");
/** /**
* TagSub plugin main class * TagSub plugin main class

ファイルの表示

@ -28,9 +28,9 @@
*/ */
if (!defined('GNUSOCIAL')) { exit(1); } if (!defined('GNUSOCIAL')) { exit(1); }
include("lib/webfingerresource.php"); include("../plugins/WebFinger/lib/webfingerresource.php");
include("lib/webfingerresource/notice.php"); include("../plugins/WebFinger/lib/webfingerresource/notice.php");
include("lib/webfingerresource/profile.php"); include("../plugins/WebFinger/lib/webfingerresource/profile.php");
class WebFingerPlugin extends Plugin class WebFingerPlugin extends Plugin
{ {

ファイルの表示

@ -25,8 +25,8 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("lib/queuedxmpp.php"); include("../plugins/Xmpp/lib/queuedxmpp.php");
include("lib/xmppmanager.php"); include("../plugins/Xmpp/lib/xmppmanager.php");
/** /**
* Plugin for XMPP * Plugin for XMPP

ファイルの表示

@ -20,6 +20,7 @@
*/ */
defined('GNUSOCIAL') || die(); defined('GNUSOCIAL') || die();
include("../plugins/Xmpp/lib/sharingxmpp.php");
use XMPPHP\Log; use XMPPHP\Log;

ファイルの表示

@ -62,6 +62,7 @@ define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
define('GNUSOCIAL', true); define('GNUSOCIAL', true);
define('STATUSNET', true); // compatibility define('STATUSNET', true); // compatibility
include ("../debug.php");
include("../lib/util/util.php"); include("../lib/util/util.php");
$user = null; $user = null;

ファイルの表示

@ -9,6 +9,20 @@ use Embed\Providers;
*/ */
class Webpage extends Adapter class Webpage extends Adapter
{ {
public $url;
public $authorName;
public $title;
public $description;
public $width;
public $height;
public $code;
public $type;
public $imageWidth;
public $imageHeight;
public $imagesUrls;
public $images;
public $image;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

ファイルの表示

@ -313,7 +313,8 @@ class Url
*/ */
public function getPath() public function getPath()
{ {
$path = !empty($this->info['path']) ? '/'.implode('/', array_map('self::urlEncode', $this->info['path'])).'/' : '/'; $path = !empty($this->info['path']) ? '/' . implode('/', array_map('Url::urlEncode', $this->info['path'])) . '/' : '/';
if (isset($this->info['file'])) { if (isset($this->info['file'])) {
$path .= self::urlEncode($this->info['file']); $path .= self::urlEncode($this->info['file']);
@ -641,7 +642,7 @@ class Url
function ($matches) { function ($matches) {
return rawurlencode($matches[0]); return rawurlencode($matches[0]);
}, },
$url $url ?? ""
); );
$parts = parse_url($enc_url); $parts = parse_url($enc_url);

ファイルの表示

@ -48,7 +48,7 @@ class OEmbed extends Provider
{ {
$type = $this->bag->get('type'); $type = $this->bag->get('type');
if (strpos($type, ':') !== false) { if (strpos($type ?? "", ':') !== false) {
$type = substr(strrchr($type, ':'), 1); $type = substr(strrchr($type, ':'), 1);
} }

ファイルの表示

@ -235,7 +235,7 @@ class Utils
$encodings = array_map('strtoupper', mb_list_encodings()); $encodings = array_map('strtoupper', mb_list_encodings());
if (in_array($charset, $encodings, true)) { if (in_array($charset, $encodings, true)) {
return mb_convert_encoding($content, 'UTF-8', $charset); return htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
} }
if (function_exists('iconv')) { if (function_exists('iconv')) {
@ -306,7 +306,7 @@ class Utils
$detected = mb_detect_encoding($string, implode(',', array_keys(self::$encodings)), true); $detected = mb_detect_encoding($string, implode(',', array_keys(self::$encodings)), true);
if ($detected && isset(self::$encodings[$detected])) { if ($detected && isset(self::$encodings[$detected])) {
$string = mb_convert_encoding($string, 'HTML-ENTITIES', $detected); $string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $detected);
$string = preg_replace( $string = preg_replace(
'/<head[^>]*>/', '/<head[^>]*>/',
'<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset='.self::$encodings[$detected].'">', '<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset='.self::$encodings[$detected].'">',

ファイルの表示

@ -90,36 +90,14 @@ class UTF8Utils
* converted to U+FFFD REPLACEMENT CHARACTER code points. * converted to U+FFFD REPLACEMENT CHARACTER code points.
*/ */
// mb_convert_encoding is chosen over iconv because of a bug. The best // htmlspecialchars is chosen over iconv because of a bug. The best
// details for the bug are on http://us1.php.net/manual/en/function.iconv.php#108643 // details for the bug are on http://us1.php.net/manual/en/function.iconv.php#108643
// which contains links to the actual but reports as well as work around // which contains links to the actual but reports as well as work around
// details. // details.
if (function_exists('mb_convert_encoding')) { $save = mb_substitute_character();
// mb library has the following behaviors: mb_substitute_character('none');
// - UTF-16 surrogates result in false. $data = htmlspecialchars($data, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
// - Overlongs and outside Plane 16 result in empty strings. mb_substitute_character($save);
// Before we run mb_convert_encoding we need to tell it what to do with
// characters it does not know. This could be different than the parent
// application executing this library so we store the value, change it
// to our needs, and then change it back when we are done. This feels
// a little excessive and it would be great if there was a better way.
$save = mb_substitute_character();
mb_substitute_character('none');
$data = mb_convert_encoding($data, 'UTF-8', $encoding);
mb_substitute_character($save);
}
// @todo Get iconv running in at least some environments if that is possible.
elseif (function_exists('iconv') && 'auto' !== $encoding) {
// fprintf(STDOUT, "iconv found\n");
// iconv has the following behaviors:
// - Overlong representations are ignored.
// - Beyond Plane 16 is replaced with a lower char.
// - Incomplete sequences generate a warning.
$data = @iconv($encoding, 'UTF-8//IGNORE', $data);
} else {
throw new Exception('Not implemented, please install mbstring or iconv');
}
/* /*
* One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present. * One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present.

ファイルの表示

@ -93,7 +93,7 @@ function fetch($url, $convertClassic = true, &$curlInfo=null) {
* @return string * @return string
*/ */
function unicodeToHtmlEntities($input) { function unicodeToHtmlEntities($input) {
return mb_convert_encoding($input, 'HTML-ENTITIES', mb_detect_encoding($input)); return htmlspecialchars($input, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
} }
/** /**
@ -112,7 +112,7 @@ function collapseWhitespace($str) {
function unicodeTrim($str) { function unicodeTrim($str) {
// this is cheating. TODO: find a better way if this causes any problems // this is cheating. TODO: find a better way if this causes any problems
$str = str_replace(mb_convert_encoding('&nbsp;', 'UTF-8', 'HTML-ENTITIES'), ' ', $str); $str = str_replace(htmlspecialchars('&nbsp;', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'), ' ', $str);
$str = preg_replace('/^\s+/', '', $str); $str = preg_replace('/^\s+/', '', $str);
return preg_replace('/\s+$/', '', $str); return preg_replace('/\s+$/', '', $str);
} }

ファイルの表示

@ -23,7 +23,7 @@ class ParserTest extends PHPUnit_Framework_TestCase {
public function testUnicodeTrim() { public function testUnicodeTrim() {
$this->assertEquals('thing', Mf2\unicodeTrim(' thing ')); $this->assertEquals('thing', Mf2\unicodeTrim(' thing '));
$this->assertEquals('thing', Mf2\unicodeTrim(' thing ')); $this->assertEquals('thing', Mf2\unicodeTrim(' thing '));
$this->assertEquals('thing', Mf2\unicodeTrim(mb_convert_encoding(' &nbsp; thing &nbsp; ', 'UTF-8', 'HTML-ENTITIES') )); $this->assertEquals('thing', Mf2\unicodeTrim(htmlspecialchars(' &nbsp; thing &nbsp; ', ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') ));
} }
public function testMicroformatNameFromClassReturnsFullRootName() { public function testMicroformatNameFromClassReturnsFullRootName() {