Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where emojis in contrib title cause SQL error #390

Draft
wants to merge 3 commits into
base: 3.3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/controllers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ services:
- '@phpbb.titania.attachment.uploader'
- '@phpbb.titania.attachment.uploader'
- '@phpbb.titania.subscriptions'
- '@text_formatter.parser'
- '@text_formatter.utils'

phpbb.titania.controller.contrib.revision:
class: phpbb\titania\controller\contribution\revision
Expand All @@ -216,6 +218,8 @@ services:
- '@phpbb.titania.attachment.uploader'
- '@phpbb.titania.subscriptions'
- '@phpbb.titania.message'
- '@text_formatter.parser'
- '@text_formatter.utils'

phpbb.titania.controller.contrib.revision.edit:
class: phpbb\titania\controller\contribution\revision_edit
Expand Down
19 changes: 18 additions & 1 deletion controller/contribution/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class manage extends base
/** @var \phpbb\titania\subscriptions */
protected $subscriptions;

/** @var \phpbb\textformatter\s9e\parser */
protected $parser;

/** @var \phpbb\textformatter\s9e\utils */
protected $utils;

/** @var bool */
protected $is_moderator;

Expand Down Expand Up @@ -68,15 +74,19 @@ class manage extends base
* @param \phpbb\titania\attachment\uploader $screenshots
* @param \phpbb\titania\attachment\uploader $colorizeit_sample
* @param \phpbb\titania\subscriptions $subscriptions
* @param \phpbb\textformatter\s9e\parser $parser
* @param \phpbb\textformatter\s9e\utils $utils
*/
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\message\message $message, \phpbb\titania\attachment\uploader $screenshots, \phpbb\titania\attachment\uploader $colorizeit_sample, \phpbb\titania\subscriptions $subscriptions)
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\message\message $message, \phpbb\titania\attachment\uploader $screenshots, \phpbb\titania\attachment\uploader $colorizeit_sample, \phpbb\titania\subscriptions $subscriptions, \phpbb\textformatter\s9e\parser $parser, \phpbb\textformatter\s9e\utils $utils)
{
parent::__construct($auth, $config, $db, $template, $user, $helper, $types, $request, $cache, $ext_config, $display, $access);

$this->message = $message;
$this->screenshots = $screenshots;
$this->colorizeit_sample = $colorizeit_sample;
$this->subscriptions = $subscriptions;
$this->parser = $parser;
$this->utils = $utils;
}

/**
Expand Down Expand Up @@ -490,6 +500,9 @@ protected function submit($authors, $old_settings)
// Set custom field values.
$this->contrib->set_custom_fields($this->settings['custom']);

// Parse the contrib name so emojis can be used
$this->contrib->contrib_name = $this->parser->parse($this->contrib->contrib_name);

// Create relations
$this->contrib->put_contrib_in_categories(
$this->settings['categories'],
Expand Down Expand Up @@ -708,6 +721,10 @@ protected function assign_vars($error)
$this->contrib->type->id
);
}

// Unparse the contrib name
$this->contrib->contrib_name = $this->utils->unparse($this->contrib->contrib_name);

$this->message->display();
$this->contrib->assign_details();
$this->display->assign_global_vars();
Expand Down
16 changes: 15 additions & 1 deletion controller/contribution/revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class revision extends base
/** @var bool */
private $skip_epv = false;

/** @var \phpbb\textformatter\s9e\parser */
protected $parser;

/** @var \phpbb\textformatter\s9e\utils */
protected $utils;

/**
* Constructor
*
Expand All @@ -71,15 +77,20 @@ class revision extends base
* @param \phpbb\titania\attachment\uploader $uploader
* @param \phpbb\titania\subscriptions $subscriptions
* @param \phpbb\titania\message\message $message
* @param \phpbb\textformatter\s9e\parser $parser
* @param \phpbb\textformatter\s9e\utils $utils
*/
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\attachment\uploader $uploader, \phpbb\titania\subscriptions $subscriptions, \phpbb\titania\message\message $message)
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\template\template $template, \phpbb\user $user, \phpbb\titania\controller\helper $helper, type_collection $types, \phpbb\request\request $request, \phpbb\titania\cache\service $cache, \phpbb\titania\config\config $ext_config, \phpbb\titania\display $display, \phpbb\titania\access $access, \phpbb\titania\attachment\uploader $uploader, \phpbb\titania\subscriptions $subscriptions, \phpbb\titania\message\message $message, \phpbb\textformatter\s9e\parser $parser, \phpbb\textformatter\s9e\utils $utils)
{
parent::__construct($auth, $config, $db, $template, $user, $helper, $types, $request, $cache, $ext_config, $display, $access);

$this->uploader = $uploader;
$this->subscriptions = $subscriptions;
$this->message = $message;

$this->parser = $parser;
$this->utils = $utils;

// Increase timeout when dealing with revisions
@set_time_limit(90);
}
Expand Down Expand Up @@ -217,6 +228,9 @@ public function add($contrib_type, $contrib)
// Load the revisions for this contribution
$this->contrib->get_revisions();

// Unparse the contrib name
$this->contrib->contrib_name = $this->utils->unparse($this->contrib->contrib_name);

if (sizeof($this->contrib->revisions))
{
// Find out what the previous revision was, if this is a new revision to an existing contribution
Expand Down