Skip to content

Commit

Permalink
Merge branch '3.2' into 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Mar 17, 2024
2 parents 4d7024d + 75fbeb0 commit ff550ec
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ This is a log of major user-visible changes in each phpMyFAQ release.
- updated bundled dependencies (Thorsten)
- fixed minor bugs (Thorsten)

### phpMyFAQ v3.2.6 - unreleased

### phpMyFAQ v3.2.5 - 2024-02-05

- fixed multiple security vulnerabilities (Thorsten)
Expand Down
5 changes: 5 additions & 0 deletions phpmyfaq/admin/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,11 @@ class="form-check-input permission">
<td class="text-center">
<i class="fa <?= $user->getUserData('is_visible') ? 'bi-person-fill' : 'bi-person' ?>"></i>
</td>
<td>
<a href="mailto:<?= Strings::htmlentities($user->getUserData('email')) ?>">
<?= Strings::htmlentities($user->getUserData('email')) ?>
</a>
</td>

<td>
<a href="?action=user&amp;user_id=<?= $user->getUserData('user_id') ?>"
Expand Down
4 changes: 4 additions & 0 deletions phpmyfaq/news.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use phpMyFAQ\Entity\CommentType;
use phpMyFAQ\Filter;
use phpMyFAQ\Glossary;
use phpMyFAQ\Helper\FaqHelper;
use phpMyFAQ\News;
use phpMyFAQ\Session\Token;
use phpMyFAQ\Strings;
Expand Down Expand Up @@ -65,6 +66,9 @@
$newsContent = $oGlossary->insertItemsIntoContent($newsContent ?? '');
$newsHeader = $oGlossary->insertItemsIntoContent($newsHeader ?? '');

$helper = new FaqHelper($faqConfig);
$newsContent = $helper->cleanUpContent($newsContent);

// Add an information link if existing
if (strlen((string) $news['link']) > 0) {
$newsContent .= sprintf(
Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/src/phpMyFAQ/Attachment/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function save($filePath, $filename = null): bool
$targetFile = $this->buildFilePath();

if (null !== $this->id && $this->createSubDirs($targetFile)) {
// Doing this check we're sure not to unnecessary
// Doing this check, we're sure not to unnecessarily
// overwrite existing unencrypted file duplicates.
if (!$this->linkedRecords()) {
$vanillaFile = new VanillaFile($filePath);
Expand Down
7 changes: 4 additions & 3 deletions phpmyfaq/src/phpMyFAQ/Category/CategoryImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,19 @@ private function getFileExtension(string $mimeType): string
$mapping = [
'image/gif' => 'gif',
'image/jpeg' => 'jpg',
'image/png' => 'png'
'image/png' => 'png',
'image/webp' => 'webp',
];

return $mapping[$mimeType] ?? '';
return $mapping[$mimeType] ?? 'png';
}

/**
* Checks for valid image MIME types, returns true if valid
*/
private function isValidMimeType(string $file): bool
{
$types = ['image/jpeg','image/gif','image/png'];
$types = ['image/jpeg','image/gif','image/png', 'image/webp'];
$type = mime_content_type($file);

return in_array($type, $types);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public function list(Request $request): Response
{
$this->userHasPermission(PermissionType::CONFIGURATION_EDIT);

$configuration = Configuration::getConfigurationInstance();

$mode = $request->get('mode');

$configurationList = Translation::getConfigurationItems($mode);
Expand All @@ -57,7 +55,7 @@ public function list(Request $request): Response
[
'mode' => $mode,
'configurationList' => $configurationList,
'configurationData' => $configuration->getAll(),
'configurationData' => $this->configuration->getAll(),
'specialCases' => [
'ldapSupport' => extension_loaded('ldap'),
'useSslForLogins' => Request::createFromGlobals()->isSecure(),
Expand All @@ -76,12 +74,9 @@ public function save(Request $request): JsonResponse
{
$this->userHasPermission(PermissionType::CONFIGURATION_EDIT);

$configuration = Configuration::getConfigurationInstance();
$jsonResponse = new JsonResponse();

$csrfToken = $request->get('pmf-csrf-token');
$configurationData = $request->get('edit');
$oldConfigurationData = $configuration->getAll();
$oldConfigurationData = $this->configuration->getAll();

if (!Token::getInstance()->verifyToken('configuration', $csrfToken)) {
return $this->json(['error' => Translation::get('err_NotAuth')], Response::HTTP_UNAUTHORIZED);
Expand All @@ -106,6 +101,14 @@ public function save(Request $request): JsonResponse
unset($configurationData['main.currentVersion']); // don't update the version number
}

if (isset($configurationData['records.attachmentsPath'])) {
$configurationData['records.attachmentsPath'] = str_replace(
'../',
'',
$configurationData['records.attachmentsPath']
);
}

if (
isset($configurationData['main.referenceURL']) &&
is_null(Filter::filterVar($configurationData['main.referenceURL'], FILTER_VALIDATE_URL))
Expand Down Expand Up @@ -140,7 +143,7 @@ public function save(Request $request): JsonResponse
}
}

$configuration->update($newConfigValues);
$this->configuration->update($newConfigValues);

return $this->json(['success' => Translation::get('ad_config_saved')], Response::HTTP_OK);
}
Expand All @@ -154,7 +157,6 @@ public function translations(): Response
{
$this->userIsAuthenticated();

$configuration = Configuration::getConfigurationInstance();
$response = new Response();

$languages = LanguageHelper::getAvailableLanguages();
Expand All @@ -163,7 +165,7 @@ public function translations(): Response
str_replace(
[ 'language_', '.php', ],
'',
(string) $configuration->get('main.language')
(string) $this->configuration->get('main.language')
),
false,
true
Expand Down
10 changes: 5 additions & 5 deletions phpmyfaq/src/phpMyFAQ/Faq.php
Original file line number Diff line number Diff line change
Expand Up @@ -950,13 +950,13 @@ public function create(FaqEntity $faqEntity): int
$this->configuration->getDb()->escape($faqEntity->getQuestion()),
$this->configuration->getDb()->escape($faqEntity->getAnswer()),
$this->configuration->getDb()->escape($faqEntity->getAuthor()),
$faqEntity->getEmail(),
$this->configuration->getDb()->escape($faqEntity->getEmail()),
$faqEntity->isComment() ? 'y' : 'n',
$faqEntity->getUpdatedDate()->format('YmdHis'),
'00000000000000',
'99991231235959',
date('Y-m-d H:i:s'),
$faqEntity->getNotes()
$this->configuration->getDb()->escape($faqEntity->getNotes())
);

$this->configuration->getDb()->query($query);
Expand Down Expand Up @@ -1017,14 +1017,14 @@ public function update(FaqEntity $faqEntity): bool
$this->configuration->getDb()->escape($faqEntity->getQuestion()),
$this->configuration->getDb()->escape($faqEntity->getAnswer()),
$this->configuration->getDb()->escape($faqEntity->getAuthor()),
$faqEntity->getEmail(),
$this->configuration->getDb()->escape($faqEntity->getEmail()),
$faqEntity->isComment() ? 'y' : 'n',
$faqEntity->getUpdatedDate()->format('YmdHis'),
$faqEntity->getValidFrom()->format('YmdHis'),
$faqEntity->getValidTo()->format('YmdHis'),
$faqEntity->getNotes(),
$this->configuration->getDb()->escape($faqEntity->getNotes()),
$faqEntity->getId(),
$faqEntity->getLanguage()
$this->configuration->getDb()->escape($faqEntity->getLanguage())
);

return (bool) $this->configuration->getDb()->query($query);
Expand Down

0 comments on commit ff550ec

Please sign in to comment.