Skip to content

Commit bddcad5

Browse files
Merge branch 'sync' into 'develop'
chore: sync mono develop See merge request 2pisoftware/cosine/core!442
2 parents 078fcba + d65f644 commit bddcad5

File tree

25 files changed

+328
-366
lines changed

25 files changed

+328
-366
lines changed

system/config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,6 @@
9595
],
9696
]);
9797

98+
Config::set('system.include_frame_options_header', true); // set to false to disable X-Frame-Options header
99+
98100
Config::set('system.use_api', true);

system/modules/auth/models/AuthService.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,11 @@ public function allowed($path, $url = null)
337337
// If I have an authentication header: and it has a token -> else fallthrough to original logic
338338
// ie: expecting [...curl...etc...] -H "Authorization: Bearer {token}"
339339
/*
340-
Note! If under Apache & HTTP_AUTHORIZATION is dropped, prove site HTPPS and then patch access:
341-
RewriteEngine On
342-
RewriteCond %{HTTP:Authorization} ^(.+)$
343-
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
344-
*/
340+
Note! If under Apache & HTTP_AUTHORIZATION is dropped, prove site HTPPS and then patch access:
341+
RewriteEngine On
342+
RewriteCond %{HTTP:Authorization} ^(.+)$
343+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
344+
*/
345345

346346
if (empty($this->user()) && (Config::get('system.use_api') === true) && !empty($_SERVER['HTTP_AUTHORIZATION'])) {
347347
$speculativeToken = TokensService::getInstance($this->w)->getTokenFromAuthorisationHeader($_SERVER['HTTP_AUTHORIZATION']);

system/modules/auth/models/User.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@ public function allowed($path)
408408
public function encryptPassword($password)
409409
{
410410
// If User's password salt is not built into the password hash use SHA1.
411-
// Should not be used in Cmfive v5
412-
// if (!empty($this->password_salt)) {
413-
// return sha1($this->password_salt . $password);
414-
// }
411+
// This is actually necessary to prevent issues rehashing SHA1 passwords to the new bcrypt hash
412+
if (!empty($this->password_salt)) {
413+
return sha1($this->password_salt . $password);
414+
}
415415

416416
$hash = false;
417417
$algorithm = PASSWORD_DEFAULT;
@@ -462,11 +462,16 @@ public function updatePasswordHash($password)
462462
return false;
463463
}
464464

465-
if (!empty($this->password_salt)) {
466-
$this->password_salt = null;
465+
// This will need to change if we ever want to rehash to another algorithm.
466+
if (startsWith($this->password, "$2y$")) {
467+
// The password is already using bcrypt.
468+
return false;
467469
}
470+
471+
$this->password_salt = null;
468472

469-
// $this->setPassword($password);
473+
// Actually set the password to the new hash.
474+
$this->setPassword($password);
470475
return $this->update(true);
471476
}
472477

system/modules/channels/models/EmailChannelOption.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct($params)
3434
$host = isset($params->host) ? $params->host : 'localhost';
3535
$password = isset($params->password) ? $params->password : '';
3636
$port = isset($params->port) ? $params->port : null;
37-
$ssl = isset($params->ssl) ? $params->ssl : false;
37+
$ssl = isset($params->ssl) ? ($port !== 993 ? "tls" : $params->ssl) : false;
3838
$options = isset($params->options) ? $params->options : null;
3939

4040
$this->protocol = new ZendMailProtocolImap();
@@ -78,10 +78,10 @@ public function connect($host, $port = null, $ssl = false, $options = [])
7878
ErrorHandler::start();
7979

8080
// Use stream_context_create instead of fsockopen as it allows us to specify SSL stream options
81-
$stream = stream_context_create();
82-
if ($ssl !== false && !is_null($options) && is_array($options) && array_key_exists('ssl', $options)) {
83-
stream_context_set_option($stream, $options);
84-
}
81+
$stream = stream_context_create($options);
82+
// if ($ssl !== false && !is_null($options) && is_array($options) && array_key_exists('ssl', $options)) {
83+
// stream_context_set_option($stream, $options);
84+
// }
8585

8686
$this->socket = stream_socket_client($host . ':' . $port, $errno, $errstr, self::TIMEOUT_CONNECTION, STREAM_CLIENT_CONNECT, $stream);
8787

system/modules/file/actions/multipart/ajax_done.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ function ajax_done_POST(Web $w)
2121

2222
$obj->delete();
2323

24+
$w->callHook(
25+
"file",
26+
"multipart_upload_done",
27+
$attachment !== true
28+
? [
29+
"attachment" => $attachment
30+
]
31+
: null
32+
);
33+
2434
$w->out(
2535
(new JsonResponse())
2636
->setSuccessfulResponse(

system/modules/file/assets/ts/MultipartUploaderComponent.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ const upload = async (e: SubmitEvent) => {
5959
done.value = true;
6060
6161
// This is kind of awful, sorry
62-
//@ts-ignore
63-
cmfiveEventBus
64-
.dispatchEvent(new CustomEvent("multipart-upload-success", {
65-
detail: {
66-
files: files.value,
67-
}
68-
}));
62+
if (failed_count.value === 0) {
63+
//@ts-ignore
64+
cmfiveEventBus
65+
.dispatchEvent(new CustomEvent("multipart-upload-success", {
66+
detail: {
67+
files: files.value,
68+
}
69+
}));
70+
}
6971
};
7072
7173
const updateFilePreview = (event: ChangeEvent<HTMLInputElement>) => {

system/modules/file/config.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
],
1414
'hooks' => [
1515
'admin',
16-
'core_web'
16+
'core_web',
17+
"file",
1718
],
1819
'adapters' => [
1920
'local' => [
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<?php
22

3-
class FileMultipartDisplaynameMigration extends CmfiveMigration {
4-
public function up() {
3+
class FileMultipartDisplaynameMigration extends CmfiveMigration
4+
{
5+
public function up()
6+
{
57
$this->addColumnToTable("file_s3_object", "display_name", "text", ["null" => true]);
68
}
79

8-
public function down() {
10+
public function down()
11+
{
912
$this->removeColumnFromTable("file_s3_object", "display_name");
1013
}
11-
}
14+
}

system/modules/file/models/FileMultipartUploadService.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,14 @@ public function finishMultipart(FileS3Object $obj)
103103
return $existing;
104104
}
105105

106+
$slash_pos = strpos($obj->key_path, "/");
107+
$filename = !$slash_pos ? $obj->key_path : substr($obj->key_path, $slash_pos + 1);
108+
106109
$attachment = new Attachment($this->w);
110+
$attachment->title = $obj->display_name;
107111
$attachment->parent_table = $obj->parent_table;
108112
$attachment->parent_id = $obj->parent_id;
109-
$attachment->filename = substr($obj->key_path, strpos($obj->key_path, "/") + 1);
110-
$attachment->title = $obj->display_name;
113+
$attachment->filename = $filename;
111114
$attachment->adapter = "s3";
112115
$attachment->fullpath = $obj->key_path;
113116
$attachment->skip_path_prefix = true;

system/modules/report/actions/edit.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ function edit_POST(Web $w)
177177
{
178178
$p = $w->pathMatch("id");
179179

180+
/**
181+
* @var Report $report
182+
*/
180183
$report = !empty($p['id']) ? ReportService::getInstance($w)->getReport($p['id']) : new Report($w);
181184
if (!empty($p['id']) && empty($report->id)) {
182185
$w->error("Report not found", "/report");
@@ -201,6 +204,9 @@ function edit_POST(Web $w)
201204

202205
// Insert or Update
203206
$report->fill($_POST);
207+
if (isset($_POST['report_code'])) {
208+
$report->report_code = json_decode($_POST['report_code']);
209+
}
204210

205211
// Force select statements only
206212
$report->sqltype = "select";

0 commit comments

Comments
 (0)