Skip to content

Commit 02af92e

Browse files
committed
Merge branch '3.2'
2 parents ea92806 + c5f0f73 commit 02af92e

File tree

20 files changed

+780
-824
lines changed

20 files changed

+780
-824
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@ This is a log of major user-visible changes in each phpMyFAQ release.
4141
- migrated from SwiftMailer to Symfony Mailer (Thorsten)
4242
- migrated codebase to use PHP 8.1 language features (Thorsten)
4343
- updated to Bootstrap v5.3 (Thorsten)
44-
- updated to TinyMCE v6.4 (Thorsten)
44+
- updated to TinyMCE v6.6 (Thorsten)
4545
- updated to PHPUnit v10 (Thorsten)
4646
- updated Japanese translation (Advanced Bear)
4747
- updated Dutch translation (Bob Coret)
4848

49+
### phpMyFAQ v3.1.16 - 2023-07-16
50+
51+
- fixed multiple security vulnerabilities (Thorsten)
52+
- fixed minor bugs (Thorsten)
53+
4954
### phpMyFAQ v3.1.15 - 2023-06-17
5055

5156
- fixed minor bugs (Thorsten)

composer.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpmyfaq/admin/api/user.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use phpMyFAQ\Filter;
2323
use phpMyFAQ\Helper\MailHelper;
2424
use phpMyFAQ\Permission;
25+
use phpMyFAQ\Report;
2526
use phpMyFAQ\Session\Token;
2627
use phpMyFAQ\Strings;
2728
use phpMyFAQ\Translation;
@@ -94,8 +95,8 @@
9495
$userObject->status = $user->getStatus();
9596
$userObject->isSuperAdmin = $user->isSuperAdmin();
9697
$userObject->isVisible = $user->getUserData('is_visible');
97-
$userObject->displayName = $user->getUserData('display_name');
98-
$userObject->userName = $user->getLogin();
98+
$userObject->displayName = Report::sanitize($user->getUserData('display_name'));
99+
$userObject->userName = Report::sanitize($user->getLogin());
99100
$userObject->email = $user->getUserData('email');
100101
$userObject->authSource = $user->getUserAuthSource();
101102
$userData[] = $userObject;

phpmyfaq/admin/report.export.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@
122122

123123
$content = '';
124124
foreach ($text as $row) {
125-
$content .= implode(';', $row);
125+
$csvRow = array_map(['phpMyFAQ\Report', 'sanitize'], $row);
126+
$content .= implode(';', $csvRow);
126127
$content .= "\r\n";
127128
}
128129

phpmyfaq/content/core/config/constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
*
114114
* - hash (default)
115115
* - bcrypt
116-
* - crypt (not recommended)
116+
* - crypt (not recommended, marked as deprecated, will be removed with v3.3)
117117
*
118118
* WARNING: DO NOT CHANGE THIS VALUE AFTER YOUR INITIAL INSTALLATION!
119119
* OTHERWISE, ALL YOUR REGISTERED USERS HAVE TO REQUEST A NEW PASSWORD.

phpmyfaq/register.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
$request = Request::createFromGlobals();
3131

3232
if (!$faqConfig->get('security.enableRegistration')) {
33-
$response = new RedirectResponse('$faqSystem->getSystemUri($faqConfig)');
34-
$response->send();
33+
$redirect = new RedirectResponse($faqSystem->getSystemUri($faqConfig));
34+
$redirect->send();
3535
}
3636

3737
try {

phpmyfaq/services/azure/callback.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717

1818
use GuzzleHttp\Exception\GuzzleException;
1919
use phpMyFAQ\Auth\AuthAzureActiveDirectory;
20+
use phpMyFAQ\Configuration;
2021
use phpMyFAQ\Filter;
2122
use phpMyFAQ\Session;
2223
use phpMyFAQ\Auth\Azure\OAuth;
2324
use phpMyFAQ\User\CurrentUser;
2425
use Symfony\Component\HttpFoundation\RedirectResponse;
2526

27+
session_start();
28+
session_regenerate_id(true);
29+
2630
//
2731
// Prepend and start the PHP session
2832
//
@@ -36,13 +40,17 @@
3640
require PMF_ROOT_DIR . '/src/Bootstrap.php';
3741
require PMF_CONFIG_DIR . '/azure.php';
3842

43+
$faqConfig = Configuration::getConfigurationInstance();
44+
3945
$code = Filter::filterInput(INPUT_GET, 'code', FILTER_SANITIZE_SPECIAL_CHARS);
4046
$error = Filter::filterInput(INPUT_GET, 'error_description', FILTER_SANITIZE_SPECIAL_CHARS);
4147

4248
$session = new Session($faqConfig);
4349
$oAuth = new OAuth($faqConfig, $session);
4450
$auth = new AuthAzureActiveDirectory($faqConfig, $oAuth);
4551

52+
$redirect = new RedirectResponse($faqConfig->getDefaultUrl());
53+
4654
if ($session->getCurrentSessionKey()) {
4755
try {
4856
$token = $oAuth->getOAuthToken($code);
@@ -76,14 +84,14 @@
7684
$user->setSuccess(true);
7785

7886
// @todo -> redirect to where the user came from
79-
$response = new RedirectResponse($faqConfig->getDefaultUrl());
80-
$response->send();
87+
$redirect->send();
8188
} catch (GuzzleException $e) {
8289
echo $e->getMessage();
8390
} catch (Exception $e) {
8491
echo $e->getMessage();
8592
}
8693
} else {
87-
$response = new RedirectResponse($faqConfig->getDefaultUrl());
88-
$response->send();
94+
$redirect->send();
8995
}
96+
97+

phpmyfaq/services/twitter/clearsessions.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
88
* obtain one at https://mozilla.org/MPL/2.0/.
99
*
10-
* @package phpMyFAQ
11-
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
10+
* @package phpMyFAQ
11+
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
1212
* @copyright 2010-2023 phpMyFAQ Team
13-
* @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14-
* @link https://www.phpmyfaq.de
15-
* @since 2010-09-18
13+
* @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14+
* @link https://www.phpmyfaq.de
15+
* @since 2010-09-18
1616
*/
1717

1818
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -30,6 +30,7 @@
3030
require PMF_ROOT_DIR . '/src/Bootstrap.php';
3131

3232
session_destroy();
33+
session_start();
3334

3435
$response = new RedirectResponse('./connect.php');
3536
$response->send();

phpmyfaq/services/twitter/index.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Abraham\TwitterOAuth\TwitterOAuth;
2020
use Abraham\TwitterOAuth\TwitterOAuthException;
2121
use Symfony\Component\HttpFoundation\RedirectResponse;
22+
use phpMyFAQ\Configuration;
23+
use Symfony\Component\HttpFoundation\RedirectResponse;
2224

2325
//
2426
// Prepend and start the PHP session
@@ -31,6 +33,8 @@
3133
//
3234
require PMF_ROOT_DIR . '/src/Bootstrap.php';
3335

36+
$faqConfig = Configuration::getConfigurationInstance();
37+
3438
if (
3539
empty($_SESSION['access_token']) ||
3640
empty($_SESSION['access_token']['oauth_token']) ||

phpmyfaq/services/twitter/redirect.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
use Abraham\TwitterOAuth\TwitterOAuth;
20+
use phpMyFAQ\Configuration;
2021
use Symfony\Component\HttpFoundation\RedirectResponse;
2122

2223
//
@@ -30,6 +31,8 @@
3031
//
3132
require PMF_ROOT_DIR . '/src/Bootstrap.php';
3233

34+
$faqConfig = Configuration::getConfigurationInstance();
35+
3336
$connection = new TwitterOAuth(
3437
$faqConfig->get('socialnetworks.twitterConsumerKey'),
3538
$faqConfig->get('socialnetworks.twitterConsumerSecret')

phpmyfaq/src/phpMyFAQ/EncryptionTypes/Crypt.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* Class Crypt
2424
*
2525
* @package phpMyFAQ\EncryptionTypes
26+
* @deprecated will be removed with v3.3
2627
*/
2728
class Crypt extends Encryption
2829
{

phpmyfaq/src/phpMyFAQ/Faq.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,10 @@ public function create(FaqEntity $faq): int
909909
}
910910

911911
$query = sprintf(
912-
"INSERT INTO %sfaqdata VALUES
912+
"INSERT INTO %sfaqdata
913+
(id, lang, solution_id, revision_id, active, sticky, keywords, thema, content, author, email, comment,
914+
updated, date_start, date_end, created, notes)
915+
VALUES
913916
(%d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
914917
Database::getTablePrefix(),
915918
$faq->getId(),

phpmyfaq/src/phpMyFAQ/Link.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,11 @@ public function toHtmlAnchor(): string
262262
}
263263

264264
if (!empty($this->tooltip)) {
265-
$htmlAnchor .= sprintf(' title="%s"', addslashes($this->tooltip));
265+
$htmlAnchor .= sprintf(' title="%s"', Strings::htmlentities($this->tooltip));
266266
}
267267

268268
if (!empty($this->name)) {
269-
$htmlAnchor .= sprintf(' name="%s"', $this->name);
269+
$htmlAnchor .= sprintf(' name="%s"', Strings::htmlentities($this->name));
270270
} else {
271271
if (!empty($this->url)) {
272272
$htmlAnchor .= sprintf(' href="%s"', $url);
@@ -280,10 +280,10 @@ public function toHtmlAnchor(): string
280280
}
281281
$htmlAnchor .= '>';
282282
if (('0' == $this->text) || (!empty($this->text))) {
283-
$htmlAnchor .= $this->text;
283+
$htmlAnchor .= Strings::htmlentities($this->text);
284284
} else {
285285
if (!empty($this->name)) {
286-
$htmlAnchor .= $this->name;
286+
$htmlAnchor .= Strings::htmlentities($this->name);
287287
} else {
288288
$htmlAnchor .= $url;
289289
}

phpmyfaq/src/phpMyFAQ/Report.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,18 @@ public function convertEncoding(string $outputString = ''): string
139139
$toBeRemoved = ['=', '+', '-', 'HYPERLINK'];
140140
return str_replace($toBeRemoved, '', $outputString);
141141
}
142+
143+
/**
144+
* Sanitizes input to avoid CSV injection.
145+
* @param string|int $value
146+
* @return string
147+
*/
148+
public static function sanitize($value): string
149+
{
150+
if (preg_match('/[=\+\-\@\|]/', $value)) {
151+
$value = '"' . str_replace('"', '""', $value) . '"';
152+
}
153+
154+
return $value;
155+
}
142156
}

phpmyfaq/src/phpMyFAQ/Search/Database/Mysqli.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(Configuration $config)
4848
public function search(string $searchTerm): mixed
4949
{
5050
if (is_numeric($searchTerm) && $this->config->get('search.searchForSolutionId')) {
51-
parent::search($searchTerm);
51+
return parent::search($searchTerm);
5252
} else {
5353
$relevance = $this->config->get('search.enableRelevance');
5454
$columns = $this->getResultColumns();

phpmyfaq/src/phpMyFAQ/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ public function setCookie(string $name, int|string|null $sessionId, int $timeout
404404

405405
return setcookie(
406406
$name,
407-
$sessionId,
407+
$sessionId ?? '',
408408
[
409409
'expires' => $_SERVER['REQUEST_TIME'] + $timeout,
410410
'path' => dirname((string) $_SERVER['SCRIPT_NAME']),

phpmyfaq/src/phpMyFAQ/User/CurrentUser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ public function deleteFromSession(bool $deleteCookie = false): bool
443443
}
444444

445445
session_destroy();
446+
session_start();
446447

447448
return true;
448449
}

phpmyfaq/ucp.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* @since 2012-01-12
1616
*/
1717

18+
use phpMyFAQ\Configuration;
1819
use phpMyFAQ\Services\Gravatar;
1920
use phpMyFAQ\Session\Token;
2021
use phpMyFAQ\Strings;
@@ -29,6 +30,8 @@
2930
exit();
3031
}
3132

33+
$faqConfig = Configuration::getConfigurationInstance();
34+
3235
if ($user->isLoggedIn()) {
3336
try {
3437
$faqSession->userTracking('user_control_panel', $user->getUserId());

0 commit comments

Comments
 (0)