aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-09-12 11:04:49 +0200
committerGravatar GitHub <noreply@github.com> 2024-09-12 11:04:49 +0200
commitfd1b5e9343b6fe92b4e5dfbbc2f01ddfcd010af9 (patch)
tree5cc4e7399212d2fdce401465e3590f2275b16c26 /app
parentd1f1e42c2b180f34276d7ddd1a2bfeaf4e59ed05 (diff)
Fix inversed encoding logic in paramArray (#6800)
* Fix inversed encoding logic in paramArray https://github.com/FreshRSS/FreshRSS/pull/6797#discussion_r1754661634 Also fix the possibility to use `<'&">` in shortcuts, and some minor encoding bugs in user queries * Forgot paramArrayString
Diffstat (limited to 'app')
-rw-r--r--app/Controllers/configureController.php9
-rw-r--r--app/Models/BooleanSearch.php1
-rw-r--r--app/Models/UserQuery.php2
-rw-r--r--app/views/configure/shortcut.phtml4
4 files changed, 11 insertions, 5 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index a9304376f..612129b8a 100644
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -202,7 +202,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
$this->view->list_keys = SHORTCUT_KEYS;
if (Minz_Request::isPost()) {
- $shortcuts = Minz_Request::paramArray('shortcuts');
+ $shortcuts = Minz_Request::paramArray('shortcuts', specialchars: true);
if (Minz_Request::paramBoolean('load_default_shortcuts')) {
$default = Minz_Configuration::load(FRESHRSS_PATH . '/config-user.default.php');
$shortcuts = $default['shortcuts'];
@@ -379,12 +379,13 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
$name = _t('conf.query.number', $id + 1);
}
if (!empty($params['get']) && is_string($params['get'])) {
- $queryParams['get'] = htmlspecialchars_decode($params['get'], ENT_QUOTES);
+ $queryParams['get'] = $params['get'];
}
if (!empty($params['order']) && is_string($params['order'])) {
- $queryParams['order'] = htmlspecialchars_decode($params['order'], ENT_QUOTES);
+ $queryParams['order'] = $params['order'];
}
if (!empty($params['search']) && is_string($params['search'])) {
+ // Search must be as plain text to be XML-encoded or URL-encoded depending on the situation
$queryParams['search'] = htmlspecialchars_decode($params['search'], ENT_QUOTES);
}
if (!empty($params['state']) && is_array($params['state'])) {
@@ -398,7 +399,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
$queryParams['url'] = Minz_Url::display(['params' => $queryParams]);
$queryParams['name'] = $name;
if (!empty($params['description']) && is_string($params['description'])) {
- $queryParams['description'] = htmlspecialchars_decode($params['description'], ENT_QUOTES);
+ $queryParams['description'] = $params['description'];
}
if (!empty($params['imageUrl']) && is_string($params['imageUrl'])) {
$queryParams['imageUrl'] = $params['imageUrl'];
diff --git a/app/Models/BooleanSearch.php b/app/Models/BooleanSearch.php
index 88069c461..9e9dec2a2 100644
--- a/app/Models/BooleanSearch.php
+++ b/app/Models/BooleanSearch.php
@@ -402,6 +402,7 @@ class FreshRSS_BooleanSearch {
return $this->getRawInput();
}
+ /** @return string Plain text search query. Must be XML-encoded or URL-encoded depending on the situation */
public function getRawInput(): string {
return $this->raw_input;
}
diff --git a/app/Models/UserQuery.php b/app/Models/UserQuery.php
index dcd17393e..d701b6b44 100644
--- a/app/Models/UserQuery.php
+++ b/app/Models/UserQuery.php
@@ -13,6 +13,7 @@ class FreshRSS_UserQuery {
private string $get = '';
private string $get_name = '';
private string $get_type = '';
+ /** XML-encoded name */
private string $name = '';
private string $order = '';
private FreshRSS_BooleanSearch $search;
@@ -25,6 +26,7 @@ class FreshRSS_UserQuery {
private array $categories;
/** @var array<int,FreshRSS_Tag> $labels */
private array $labels;
+ /** XML-encoded description */
private string $description = '';
private string $imageUrl = '';
diff --git a/app/views/configure/shortcut.phtml b/app/views/configure/shortcut.phtml
index 78b659120..b7930f263 100644
--- a/app/views/configure/shortcut.phtml
+++ b/app/views/configure/shortcut.phtml
@@ -16,7 +16,9 @@
<?php } ?>
</datalist>
- <?php $s = FreshRSS_Context::userConf()->shortcuts; ?>
+ <?php
+ $s = array_map(static fn(string $string) => htmlspecialchars($string, ENT_COMPAT, 'UTF-8'), FreshRSS_Context::userConf()->shortcuts);
+ ?>
<?php if ([] !== $nonStandard = getNonStandardShortcuts($s)): ?>
<p class="alert alert-error">