mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/17135] Fix code flaws
PHPBB-17135
This commit is contained in:
@@ -94,9 +94,7 @@ abstract class base
|
||||
* @param assets_bag $assets_bag
|
||||
* @param config $config
|
||||
* @param dispatcher $dispatcher
|
||||
* @param manager $ext_manager
|
||||
* @param language $language
|
||||
* @param log_interface $log
|
||||
* @param queue $queue
|
||||
* @param path_helper $path_helper
|
||||
* @param request $request
|
||||
@@ -105,14 +103,14 @@ abstract class base
|
||||
* @param user $user
|
||||
* @param string $phpbb_root_path
|
||||
* @param string $template_cache_path
|
||||
* @param manager $ext_manager
|
||||
* @param log_interface $log
|
||||
*/
|
||||
public function __construct(
|
||||
assets_bag $assets_bag,
|
||||
config $config,
|
||||
dispatcher $dispatcher,
|
||||
manager $ext_manager,
|
||||
language $language,
|
||||
log_interface $log,
|
||||
queue $queue,
|
||||
path_helper $path_helper,
|
||||
request $request,
|
||||
@@ -120,7 +118,9 @@ abstract class base
|
||||
lexer $twig_lexer,
|
||||
user $user,
|
||||
$phpbb_root_path,
|
||||
$template_cache_path
|
||||
$template_cache_path,
|
||||
?manager $ext_manager = null,
|
||||
?log_interface $log = null
|
||||
)
|
||||
{
|
||||
$this->assets_bag = $assets_bag;
|
||||
@@ -198,32 +198,6 @@ abstract class base
|
||||
$this->subject = $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds antiabuse headers
|
||||
*
|
||||
* @param config $config Config object
|
||||
* @param user $user User object
|
||||
* @return void
|
||||
*/
|
||||
abstract public function anti_abuse_headers(config $config, user $user): void;
|
||||
|
||||
/**
|
||||
* Set up extra headers
|
||||
*
|
||||
* @param string $header_name Email header name
|
||||
* @param string $header_value Email header body
|
||||
* @return void
|
||||
*/
|
||||
abstract public function header(string $header_name, string $header_value): void;
|
||||
|
||||
/**
|
||||
* Set the reply to address
|
||||
*
|
||||
* @param string $address Email "Reply to" address
|
||||
* @return void
|
||||
*/
|
||||
abstract public function reply_to($address): void;
|
||||
|
||||
/**
|
||||
* Send out messages
|
||||
*
|
||||
@@ -444,7 +418,10 @@ abstract class base
|
||||
$type = strtoupper($this->get_queue_object_name());
|
||||
$calling_page = html_entity_decode($this->request->server('PHP_SELF'), ENT_COMPAT);
|
||||
$message = '<strong>' . $type . '</strong><br><em>' . htmlspecialchars($calling_page, ENT_COMPAT) . '</em><br><br>' . $msg . '<br>';
|
||||
$this->log->add('critical', $this->user->data['user_id'], $this->user->ip, 'LOG_ERROR_' . $type, false, [$message]);
|
||||
if ($this->log)
|
||||
{
|
||||
$this->log->add('critical', $this->user->data['user_id'], $this->user->ip, 'LOG_ERROR_' . $type, false, [$message]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,11 +26,11 @@ class email extends base
|
||||
{
|
||||
/** @var array */
|
||||
private const PRIORITY_MAP = [
|
||||
Email::PRIORITY_HIGHEST => 'Highest',
|
||||
Email::PRIORITY_HIGH => 'High',
|
||||
Email::PRIORITY_NORMAL => 'Normal',
|
||||
Email::PRIORITY_LOW => 'Low',
|
||||
Email::PRIORITY_LOWEST => 'Lowest',
|
||||
symfony_email::PRIORITY_HIGHEST => 'Highest',
|
||||
symfony_email::PRIORITY_HIGH => 'High',
|
||||
symfony_email::PRIORITY_NORMAL => 'Normal',
|
||||
symfony_email::PRIORITY_LOW => 'Low',
|
||||
symfony_email::PRIORITY_LOWEST => 'Lowest',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ class email extends base
|
||||
*/
|
||||
protected $dsn = '';
|
||||
|
||||
/** @var Email */
|
||||
/** @var symfony_email */
|
||||
protected $email;
|
||||
|
||||
/** @var Address */
|
||||
@@ -53,13 +53,13 @@ class email extends base
|
||||
* @var int
|
||||
*
|
||||
* Possible values are:
|
||||
* Email::PRIORITY_HIGHEST
|
||||
* Email::PRIORITY_HIGH
|
||||
* Email::PRIORITY_NORMAL
|
||||
* Email::PRIORITY_LOW
|
||||
* Email::PRIORITY_LOWEST
|
||||
* symfony_email::PRIORITY_HIGHEST
|
||||
* symfony_email::PRIORITY_HIGH
|
||||
* symfony_email::PRIORITY_NORMAL
|
||||
* symfony_email::PRIORITY_LOW
|
||||
* symfony_email::PRIORITY_LOWEST
|
||||
*/
|
||||
protected $mail_priority = Email::PRIORITY_NORMAL;
|
||||
protected $mail_priority = symfony_email::PRIORITY_NORMAL;
|
||||
|
||||
/** @var \phpbb\messenger\queue */
|
||||
protected $queue;
|
||||
@@ -102,7 +102,7 @@ class email extends base
|
||||
$this->email = new symfony_email();
|
||||
$this->headers = $this->email->getHeaders();
|
||||
$this->subject = $this->msg = '';
|
||||
$this->mail_priority = Email::PRIORITY_NORMAL;
|
||||
$this->mail_priority = symfony_email::PRIORITY_NORMAL;
|
||||
|
||||
$this->additional_headers = [];
|
||||
$this->use_queue = true;
|
||||
@@ -254,16 +254,16 @@ class email extends base
|
||||
* Set the email priority
|
||||
*
|
||||
* Possible values are:
|
||||
* Email::PRIORITY_HIGHEST = 1
|
||||
* Email::PRIORITY_HIGH = 2
|
||||
* Email::PRIORITY_NORMAL = 3
|
||||
* Email::PRIORITY_LOW = 4
|
||||
* Email::PRIORITY_LOWEST = 5
|
||||
* symfony_email::PRIORITY_HIGHEST = 1
|
||||
* symfony_email::PRIORITY_HIGH = 2
|
||||
* symfony_email::PRIORITY_NORMAL = 3
|
||||
* symfony_email::PRIORITY_LOW = 4
|
||||
* symfony_email::PRIORITY_LOWEST = 5
|
||||
*
|
||||
* @param int $priority Email priority level
|
||||
* @return void
|
||||
*/
|
||||
public function set_mail_priority(int $priority = Email::PRIORITY_NORMAL): void
|
||||
public function set_mail_priority(int $priority = symfony_email::PRIORITY_NORMAL): void
|
||||
{
|
||||
$this->email->priority($priority);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ class email extends base
|
||||
|
||||
$this->email->priority($this->mail_priority);
|
||||
|
||||
$phpbb_headers = [
|
||||
$headers = [
|
||||
'Return-Path' => new Address($this->config['board_email']),
|
||||
'Sender' => new Address($this->config['board_email']),
|
||||
'X-MSMail-Priority' => self::PRIORITY_MAP[$this->mail_priority],
|
||||
@@ -301,25 +301,23 @@ class email extends base
|
||||
];
|
||||
|
||||
// Add additional headers
|
||||
$phpbb_headers = array_merge($phpbb_headers, $this->additional_headers);
|
||||
$headers = array_merge($headers, $this->additional_headers);
|
||||
|
||||
foreach ($phpbb_headers as $header => $value)
|
||||
{
|
||||
$this->headers->addHeader($header, $value);
|
||||
}
|
||||
|
||||
$headers = $this->headers;
|
||||
/**
|
||||
* Event to modify email header entries
|
||||
*
|
||||
* @event core.modify_email_headers
|
||||
* @var Headers headers Array containing email header entries
|
||||
* @var array headers Array containing email header entries
|
||||
* @since 3.1.11-RC1
|
||||
* @changed 4.0.0-a1 'headers' var type changed from array to \Symfony\Component\Mime\Header\Headers
|
||||
*/
|
||||
$vars = ['headers'];
|
||||
extract($this->dispatcher->trigger_event('core.modify_email_headers', compact($vars)));
|
||||
$this->headers = $headers;
|
||||
|
||||
foreach ($headers as $header => $value)
|
||||
{
|
||||
$this->headers->addHeader($header, $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -566,7 +564,9 @@ class email extends base
|
||||
'email' => $this->email,
|
||||
]);
|
||||
}
|
||||
$this->reset();
|
||||
|
||||
// Reset the object
|
||||
$this->init();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -359,13 +359,12 @@ class jabber extends base
|
||||
return is_resource($this->connection) && !feof($this->connection);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initiates login (using data from contructor, after calling connect())
|
||||
*
|
||||
* @return bool|void
|
||||
* @return bool|null
|
||||
*/
|
||||
public function login(): bool|void
|
||||
public function login(): bool|null
|
||||
{
|
||||
if (empty($this->features))
|
||||
{
|
||||
@@ -410,7 +409,7 @@ class jabber extends base
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function init(): void
|
||||
public function reset(): void
|
||||
{
|
||||
$this->subject = $this->msg = '';
|
||||
$this->additional_headers = $this->to = [];
|
||||
@@ -484,7 +483,7 @@ class jabber extends base
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function send(): void
|
||||
public function send(): bool
|
||||
{
|
||||
$this->prepare_message();
|
||||
|
||||
@@ -666,9 +665,9 @@ class jabber extends base
|
||||
/**
|
||||
* Initiates account registration (based on data used for contructor)
|
||||
*
|
||||
* @return bool|void
|
||||
* @return bool|null
|
||||
*/
|
||||
public function register(): bool|void
|
||||
public function register(): bool|null
|
||||
{
|
||||
if (!isset($this->session['id']) || isset($this->session['jid']))
|
||||
{
|
||||
@@ -711,9 +710,9 @@ class jabber extends base
|
||||
* This handles all the different XML elements
|
||||
*
|
||||
* @param array $xml
|
||||
* @return bool|void
|
||||
* @return bool|null
|
||||
*/
|
||||
function response(array $xml): bool|void
|
||||
function response(array $xml): bool|null
|
||||
{
|
||||
if (!is_array($xml) || !count($xml))
|
||||
{
|
||||
@@ -728,20 +727,17 @@ class jabber extends base
|
||||
{
|
||||
$this->response(array($key => $value));
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
else if (is_array(reset($xml)) && count(reset($xml)) > 1)
|
||||
{
|
||||
// or even multiple elements of the same type?
|
||||
// array('message' => array(0 => ..., 1 => ...))
|
||||
if (is_array(reset($xml)) && count(reset($xml)) > 1)
|
||||
foreach (reset($xml) as $value)
|
||||
{
|
||||
foreach (reset($xml) as $value)
|
||||
{
|
||||
$this->response(array(key($xml) => array(0 => $value)));
|
||||
}
|
||||
return;
|
||||
$this->response(array(key($xml) => array(0 => $value)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (key($xml))
|
||||
@@ -1012,6 +1008,7 @@ class jabber extends base
|
||||
$message['subject'] = $xml['message'][0]['#']['subject'][0]['#'];
|
||||
}
|
||||
$this->session['messages'][] = $message;
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1123,7 +1120,7 @@ class jabber extends base
|
||||
* @param array $data Data array
|
||||
* @return string
|
||||
*/
|
||||
public function implode_data(arary $data): string
|
||||
public function implode_data(array $data): string
|
||||
{
|
||||
$return = array();
|
||||
foreach ($data as $key => $value)
|
||||
@@ -1141,7 +1138,7 @@ class jabber extends base
|
||||
* @param string $data Data string
|
||||
* @param string|int|bool $skip_white New XML parser option value
|
||||
* @param string $encoding Encoding value
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
function xmlize(string $data, string|int|bool $skip_white = 1, string $encoding = 'UTF-8'): array
|
||||
{
|
||||
|
Reference in New Issue
Block a user