Skip to content

Commit 8a1cfbe

Browse files
Merge branch 'hotfix/3.1.4.2'
2 parents dfccb51 + 0218838 commit 8a1cfbe

File tree

10 files changed

+89
-114
lines changed

10 files changed

+89
-114
lines changed

includes/config/include.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
define('TP_VERSION', '3.1.4');
3030
define("UPGRADE_MIN_DATE", "1732981987");
31-
define('TP_VERSION_MINOR', '1');
31+
define('TP_VERSION_MINOR', '2');
3232
define('TP_TOOL_NAME', 'Teampass');
3333
define('TP_ONE_DAY_SECONDS', 86400);
3434
define('TP_ONE_WEEK_SECONDS', 604800);
@@ -67,6 +67,8 @@
6767
define('TP_PW_STRENGTH_4', 48);
6868
define('TP_PW_STRENGTH_5', 60);
6969
define('MIN_PHP_VERSION', '8.1');
70+
define('MIN_MYSQL_VERSION', '8.0.13');
71+
define('MIN_MARIADB_VERSION', '10.2.1');
7072

7173
// URLs
7274
define('READTHEDOC_URL', 'https://teampass.readthedocs.io/en/latest/');

includes/libraries/teampassclasses/emailservice/src/EmailService.php

+6-30
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,6 @@
3232
use PHPMailer\PHPMailer\Exception;
3333
use voku\helper\AntiXSS;
3434

35-
class EmailSettings
36-
{
37-
public $smtpServer;
38-
public $smtpAuth;
39-
public $authUsername;
40-
public $authPassword;
41-
public $port;
42-
public $security;
43-
public $from;
44-
public $fromName;
45-
public $debugLevel;
46-
public $dir;
47-
48-
// Constructeur pour initialiser les paramètres
49-
public function __construct(array $SETTINGS)
50-
{
51-
$this->smtpServer = $SETTINGS['email_smtp_server'];
52-
$this->smtpAuth = (int) $SETTINGS['email_smtp_auth'] === 1;
53-
$this->authUsername = $SETTINGS['email_auth_username'];
54-
$this->authPassword = $SETTINGS['email_auth_pwd'];
55-
$this->port = (int) $SETTINGS['email_port'];
56-
$this->security = $SETTINGS['email_security'];
57-
$this->from = $SETTINGS['email_from'];
58-
$this->fromName = $SETTINGS['email_from_name'];
59-
$this->debugLevel = $SETTINGS['email_debug_level'];
60-
$this->dir = $SETTINGS['cpassman_dir'];
61-
}
62-
}
63-
6435
class EmailService
6536
{
6637
protected $mailer;
@@ -102,7 +73,12 @@ public function configureMailer(EmailSettings $emailSettings, $silent, $cron)
10273
public function addRecipients($email)
10374
{
10475
foreach (array_filter(explode(',', $email)) as $dest) {
105-
$this->mailer->addAddress($dest);
76+
$dest = trim($dest);
77+
if (filter_var($dest, FILTER_VALIDATE_EMAIL)) {
78+
$this->mailer->addAddress($dest);
79+
} else {
80+
error_log("Teampass - Error - Invalid email ignored : $dest");
81+
}
10682
}
10783
}
10884

includes/libraries/teampassclasses/emailservice/src/EmailSettings.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ class EmailSettings
4444
// Constructeur pour initialiser les paramètres
4545
public function __construct(array $SETTINGS)
4646
{
47-
$this->smtpServer = $SETTINGS['email_smtp_server'];
48-
$this->smtpAuth = (int) $SETTINGS['email_smtp_auth'] === 1;
49-
$this->authUsername = $SETTINGS['email_auth_username'];
50-
$this->authPassword = $SETTINGS['email_auth_pwd'];
51-
$this->port = (int) $SETTINGS['email_port'];
52-
$this->security = $SETTINGS['email_security'];
53-
$this->from = $SETTINGS['email_from'];
54-
$this->fromName = $SETTINGS['email_from_name'];
55-
$this->debugLevel = $SETTINGS['email_debug_level'];
56-
$this->dir = $SETTINGS['cpassman_dir'];
47+
$this->smtpServer = $SETTINGS['email_smtp_server'] ?? '';
48+
$this->smtpAuth = isset($SETTINGS['email_smtp_auth']) ? ((int) $SETTINGS['email_smtp_auth']) === 1 : false;
49+
$this->authUsername = $SETTINGS['email_auth_username'] ?? '';
50+
$this->authPassword = $SETTINGS['email_auth_pwd'] ?? '';
51+
$this->port = isset($SETTINGS['email_port']) ? (int) $SETTINGS['email_port'] : 25;
52+
$this->security = $SETTINGS['email_security'] ?? 'none';
53+
$this->from = $SETTINGS['email_from'] ?? 'no-reply@example.com';
54+
$this->fromName = $SETTINGS['email_from_name'] ?? 'No Reply';
55+
$this->debugLevel = $SETTINGS['email_debug_level'] ?? 0;
56+
$this->dir = $SETTINGS['cpassman_dir'] ?? __DIR__;
5757
}
5858
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Teampass - a collaborative passwords manager.
4+
* ---
5+
* This file is part of the TeamPass project.
6+
*
7+
* TeamPass is free software: you can redistribute it and/or modify it
8+
* under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, version 3 of the License.
10+
*
11+
* TeamPass is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*
19+
* Certain components of this file may be under different licenses. For
20+
* details, see the `licenses` directory or individual file headers.
21+
* ---
22+
* @file run.step1.php
23+
* @author Nils Laumaillé (nils@teampass.net)
24+
* @copyright 2009-2025 Teampass.net
25+
* @license GPL-3.0
26+
* @see https://www.teampass.net
27+
*/
28+
29+
use Elegant\Sanitizer\Sanitizer;
30+
use voku\helper\AntiXSS;
31+
32+
// Check if function exists
33+
if (!function_exists('dataSanitizer')) {
34+
/**
35+
* Uses Sanitizer to perform data sanitization
36+
*
37+
* @param array $data
38+
* @param array $filters
39+
* @return array|string
40+
*/
41+
function dataSanitizer(array $data, array $filters): array|string
42+
{
43+
// Load Sanitizer library
44+
$sanitizer = new Sanitizer($data, $filters);
45+
46+
// Load AntiXSS
47+
$antiXss = new AntiXSS();
48+
49+
// Sanitize post and get variables
50+
return $antiXss->xss_clean($sanitizer->sanitize());
51+
}
52+
}

install/install.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
* @see https://www.teampass.net
2727
*/
2828

29-
// Define some constants
30-
define('MIN_PHP_VERSION', '8.1');
31-
define('MIN_MYSQL_VERSION', '8.0.13');
32-
define('MIN_MARIADB_VERSION', '10.2.1');
3329

3430
// Prepare autoloader
3531
require '../vendor/autoload.php';
@@ -39,9 +35,9 @@
3935
include __DIR__.'/../includes/config/include.php';
4036
// Load functions
4137
require_once __DIR__.'/tp.functions.php';
38+
require_once __DIR__.'/install-steps/install.functions.php';
4239

4340
$superGlobal = new SuperGlobal();
44-
4541
// Prepare variables
4642
$serverPath = rtrim($superGlobal->get('DOCUMENT_ROOT', 'SERVER'), '/').
4743
substr($superGlobal->get('PHP_SELF', 'SERVER'), 0,-20);

install/tp.functions.php

-21
Original file line numberDiff line numberDiff line change
@@ -683,25 +683,4 @@ function recursiveChmodForInstall(
683683

684684
// Everything seemed to work out well, return true
685685
return true;
686-
}
687-
688-
if (!function_exists('dataSanitizer')) {
689-
/**
690-
* Uses Sanitizer to perform data sanitization
691-
*
692-
* @param array $data
693-
* @param array $filters
694-
* @return array|string
695-
*/
696-
function dataSanitizer(array $data, array $filters): array|string
697-
{
698-
// Load Sanitizer library
699-
$sanitizer = new Sanitizer($data, $filters);
700-
701-
// Load AntiXSS
702-
$antiXss = new AntiXSS();
703-
704-
// Sanitize post and get variables
705-
return $antiXss->xss_clean($sanitizer->sanitize());
706-
}
707686
}

install/upgrade.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,14 @@
4444

4545
require_once './libs/SecureHandler.php';
4646
require_once '../sources/main.functions.php';
47+
require_once '../includes/config/include.php';
4748

4849
// init
4950
loadClasses();
5051
$session = SessionManager::getSession();
5152

5253
//Session teampass tag
5354
$_SESSION['CPM'] = 1;
54-
define('MIN_PHP_VERSION', '8.1');
55-
define('MIN_MYSQL_VERSION', '8.0.13');
56-
define('MIN_MARIADB_VERSION', '10.2.1');
5755

5856
// Prepare POST variables
5957
$post_root_url = filter_input(INPUT_POST, 'root_url', FILTER_SANITIZE_FULL_SPECIAL_CHARS);

install/upgrade_ajax.php

-4
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,6 @@ function settingsConsistencyCheck(): array
209209

210210
error_reporting(E_ERROR | E_PARSE);
211211
$_SESSION['CPM'] = 1;
212-
define('MIN_PHP_VERSION', '8.1');
213-
define('MIN_MYSQL_VERSION', '8.0.13');
214-
define('MIN_MARIADB_VERSION', '10.2.1');
215212

216213
// Load config
217214
$configManager = new ConfigManager();
@@ -222,7 +219,6 @@ function settingsConsistencyCheck(): array
222219
require_once '../includes/config/settings.php';
223220
require_once 'tp.functions.php';
224221

225-
226222
// Prepare POST variables
227223
$post_type = filter_input(INPUT_POST, 'type', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
228224
$post_data = filter_input(INPUT_POST, 'data', FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_FLAG_NO_ENCODE_QUOTES);

vendor/teampassclasses/emailservice/src/EmailService.php

+6-30
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,6 @@
3232
use PHPMailer\PHPMailer\Exception;
3333
use voku\helper\AntiXSS;
3434

35-
class EmailSettings
36-
{
37-
public $smtpServer;
38-
public $smtpAuth;
39-
public $authUsername;
40-
public $authPassword;
41-
public $port;
42-
public $security;
43-
public $from;
44-
public $fromName;
45-
public $debugLevel;
46-
public $dir;
47-
48-
// Constructeur pour initialiser les paramètres
49-
public function __construct(array $SETTINGS)
50-
{
51-
$this->smtpServer = $SETTINGS['email_smtp_server'];
52-
$this->smtpAuth = (int) $SETTINGS['email_smtp_auth'] === 1;
53-
$this->authUsername = $SETTINGS['email_auth_username'];
54-
$this->authPassword = $SETTINGS['email_auth_pwd'];
55-
$this->port = (int) $SETTINGS['email_port'];
56-
$this->security = $SETTINGS['email_security'];
57-
$this->from = $SETTINGS['email_from'];
58-
$this->fromName = $SETTINGS['email_from_name'];
59-
$this->debugLevel = $SETTINGS['email_debug_level'];
60-
$this->dir = $SETTINGS['cpassman_dir'];
61-
}
62-
}
63-
6435
class EmailService
6536
{
6637
protected $mailer;
@@ -102,7 +73,12 @@ public function configureMailer(EmailSettings $emailSettings, $silent, $cron)
10273
public function addRecipients($email)
10374
{
10475
foreach (array_filter(explode(',', $email)) as $dest) {
105-
$this->mailer->addAddress($dest);
76+
$dest = trim($dest);
77+
if (filter_var($dest, FILTER_VALIDATE_EMAIL)) {
78+
$this->mailer->addAddress($dest);
79+
} else {
80+
error_log("Teampass - Error - Invalid email ignored : $dest");
81+
}
10682
}
10783
}
10884

vendor/teampassclasses/emailservice/src/EmailSettings.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ class EmailSettings
4444
// Constructeur pour initialiser les paramètres
4545
public function __construct(array $SETTINGS)
4646
{
47-
$this->smtpServer = $SETTINGS['email_smtp_server'];
48-
$this->smtpAuth = (int) $SETTINGS['email_smtp_auth'] === 1;
49-
$this->authUsername = $SETTINGS['email_auth_username'];
50-
$this->authPassword = $SETTINGS['email_auth_pwd'];
51-
$this->port = (int) $SETTINGS['email_port'];
52-
$this->security = $SETTINGS['email_security'];
53-
$this->from = $SETTINGS['email_from'];
54-
$this->fromName = $SETTINGS['email_from_name'];
55-
$this->debugLevel = $SETTINGS['email_debug_level'];
56-
$this->dir = $SETTINGS['cpassman_dir'];
47+
$this->smtpServer = $SETTINGS['email_smtp_server'] ?? '';
48+
$this->smtpAuth = isset($SETTINGS['email_smtp_auth']) ? ((int) $SETTINGS['email_smtp_auth']) === 1 : false;
49+
$this->authUsername = $SETTINGS['email_auth_username'] ?? '';
50+
$this->authPassword = $SETTINGS['email_auth_pwd'] ?? '';
51+
$this->port = isset($SETTINGS['email_port']) ? (int) $SETTINGS['email_port'] : 25;
52+
$this->security = $SETTINGS['email_security'] ?? 'none';
53+
$this->from = $SETTINGS['email_from'] ?? 'no-reply@example.com';
54+
$this->fromName = $SETTINGS['email_from_name'] ?? 'No Reply';
55+
$this->debugLevel = $SETTINGS['email_debug_level'] ?? 0;
56+
$this->dir = $SETTINGS['cpassman_dir'] ?? __DIR__;
5757
}
5858
}

0 commit comments

Comments
 (0)