Commit Graph
3697 Commits
Author SHA1 Message Date
f94c101621 Harden SSRF guard: reject remaining reserved/special-use IP ranges (#9621)
* Reject remaining special-use ranges in the SSRF guard

FILTER_FLAG_GLOBAL_RANGE still accepts several reserved ranges on
supported PHP versions. Reject those explicitly, including when an
IPv4 address is embedded in the public NAT64 prefix, and keep
legitimate public NAT64 addresses allowed.

Co-authored-by: aplaton216 <aplaton216@users.noreply.github.com>

* Refactor

Fix https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-2983-h3r5-qv6j
Fix https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-8f2g-vq96-ffxw

* Doc PHP upstream

https://github.com/php/php-src/pull/25426

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: aplaton216 <aplaton216@users.noreply.github.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-25 15:20:34 +01:00
Alexandre Alapetite 5d81cd8832 Avoid duplicated enclosure titles (#9615)
Fix https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-pwpq-78jm-px4m
2026-11-24 09:14:10 +01:00
Alexandre Alapetite dcd40cb7d4 Better sanitize domains (#9611)
Fix https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-3ch8-46c3-xr9h
2026-11-22 21:57:54 +01:00
Alexandre Alapetite 6320ff8af7 More secure remove access (#9610)
Fix https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-r27w-hr3c-hjr3
2026-11-22 21:54:39 +01:00
Chareonwit KunnaandAlexandre Alapetite cf6a0a5c35 docs: fix doubled words (#9609)
* docs: fix doubled word

Signed-off-by: Chareonwit Kunna <21arenabreakout12@gmail.com>

* docs: fix doubled word

Signed-off-by: Chareonwit Kunna <21arenabreakout12@gmail.com>

* docs: fix doubled word

Signed-off-by: Chareonwit Kunna <21arenabreakout12@gmail.com>

* docs: fix doubled word

Signed-off-by: Chareonwit Kunna <21arenabreakout12@gmail.com>

* One more

---------

Signed-off-by: Chareonwit Kunna <21arenabreakout12@gmail.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-22 13:20:56 +01:00
Inverle 6a6b23bf82 Fix HTML injection in extension names (#9608)
Fix [GHSA-crc7-3qcq-m9h3](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-crc7-3qcq-m9h3)
2026-11-22 08:54:32 +01:00
Alexandre Alapetite 2855de21e3 Fix full-content logic (#9602)
Rewritten inspired by MIME multipart boundaries.
Fix https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-5hcv-wqwr-j8r8
2026-11-21 22:39:13 +01:00
Alexandre Alapetite 67cb0a2d9a Sanitize DB install params (#9595) 2026-11-20 22:41:26 +01:00
Inverle 2f31a2fdf5 Fix HTML injection in view mode error notification (#9605)
Fix [GHSA-wpf6-5v7v-6cvj](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-wpf6-5v7v-6cvj)

Introduced in https://github.com/FreshRSS/FreshRSS/pull/7668
2026-11-20 22:11:25 +01:00
Alexandre Alapetite 8ffddc11f8 More security for extension files: nosniff (#9593)
Global `X-Content-Type-Options: nosniff`
And follow-up of #7753
2026-11-20 13:54:09 +01:00
Alexandre Alapetite 13280a4dfc Safer login (#9592)
Avoid using some functions changing state before full verification.
Related to https://github.com/FreshRSS/FreshRSS/pull/9598
2026-11-20 10:24:29 +01:00
Inverle 2584514db3 Deny formLogin access if already logged in (#9598)
Follow-up of https://github.com/FreshRSS/FreshRSS/pull/9592

There is no reason for logged in users to have access to the login page.
2026-11-20 08:10:27 +01:00
Alexandre Alapetite ae664c8ccd Better sanitize bookmark (#9594) 2026-11-19 23:20:55 +01:00
Alexandre Alapetite ea646d2bde Use PHP 8.4+ \Dom classes and functions (#9567)
Currently, SimplePie uses legacy DOMDocument parsing, which outputs potentially problematic HTML, not correctly sanitised.
This breaks the assumption that one can use something like `<div><!-- some HTML sanitized from SimplePie --></div>`.

```
--- Expected
+++ Actual
@@ @@
 '<ul>
-    <li><div></div></li>
+    <li><div>
     <li>Item</li>
-</ul>'
+</div></li></ul>'
```

When shown in a compliant Web browser, several tags will be wrongly closed, breaking the layout of the client.

This PR patches SimplePie to use the modern parser and code syntax, while maintaining a best-effort polyfill for legacy PHP versions < 8.4.

Depends on:

SimplePie: Upgrade to PHPStan 2
* https://github.com/FreshRSS/simplepie/pull/97
* https://github.com/simplepie/simplepie/pull/939
* https://github.com/simplepie/simplepie/pull/1019

SimplePie: Use PHP 8.4+ \Dom classes and functions
* https://github.com/FreshRSS/simplepie/pull/98
* https://github.com/simplepie/simplepie/issues/1021

SimplePie: Add unit test for HTML5 sanitizing compliance
* https://github.com/simplepie/simplepie/pull/1022

SimplePie: Remove obsolete xml_is_sane and XMLReader fallback
* https://github.com/simplepie/simplepie/pull/1023

CssXPath: Add support for case insensitivity
* https://github.com/phpgt/CssXPath/pull/256

fix https://github.com/FreshRSS/FreshRSS/issues/5201
fix https://github.com/FreshRSS/FreshRSS/issues/6830
fix https://github.com/FreshRSS/FreshRSS/issues/6831

~5% faster for HTML sanitising.
Remove SimpleXML. Remove XMLReader.
2026-11-19 23:17:04 +01:00
Alexandre Alapetite 289a00be00 A few misc. security enhancements (#9591) 2026-11-19 20:09:02 +01:00
Alexandre Alapetite 6aeca31312 Add Cross-Origin-Opener-Policy (COOP) header (#9588)
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Cross-Origin-Opener-Policy
2026-11-19 20:08:21 +01:00
IEEE-754 3c36d36b48 i18n: Improve Traditional Chinese translations (#9590)
- Refine wording
- Add some new translations
2026-11-19 16:21:43 +01:00
Ricardo SimõesandAlexandre Alapetite c4a4924529 Update conf.php - European Portuguese pt-PT translation (#9583)
* Update conf.php - European Portuguese pt-PT translation

Translated just 1 string at line 314

* make fix-all

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-18 15:23:56 +01:00
d6c907bc04 SQLite, PostgreSQL: batch markRead for lists of IDs (#9575)
Closes #9574

Changes proposed in this pull request:

- `FreshRSS_EntryDAOSQLite::markRead()` now passes arrays of IDs to `FreshRSS_EntryDAO::markRead()`. That method already does a batched `UPDATE … WHERE is_read<>? AND id IN (…)`, split into chunks by `MAX_VARIABLE_NUMBER` (998, which also covers SQLite's parameter limit), then refreshes the unread caches once. For lists of fewer than 6 IDs it still calls back into the existing per-entry SQLite/PostgreSQL path. `FreshRSS_EntryDAOPGSQL` inherits the change.
- The `@param` type now matches the parent's `list<numeric-string>` (PHPStan `argument.type`).

How to test the feature manually:

1. Use PostgreSQL with some latency (`tc qdisc add dev eth0 root netem delay 25ms` on the database host gave about 75 ms per round trip).
2. Mark several hundred unread articles read in a single Google Reader API `edit-tag` request, or call `FreshRSS_Factory::createEntryDao()->markRead($ids, true)` from a CLI script.
3. Compare elapsed time and check that `SUM(cache_nbUnreads)` still equals the unread count in `_entry`.

My results (official `edge` image; the DAO files are identical in 1.30.4):

| Backend | Case | Before | After |
|---|---|---|---|
| PostgreSQL 17, ~75 ms RTT | mark 300 read | 60.5 s | 0.16 s |
| PostgreSQL 17, ~75 ms RTT | resend the same 300 (no change) | 37.6 s | 0.08 s |
| PostgreSQL 17, ~75 ms RTT | mark 2,500 read / unread (chunked) | not run | 0.49 s / 0.49 s |
| SQLite | mark 300 read | 1.48 s | 0.01 s |
| SQLite | mark 2,500 read / unread (chunked) | not run | 0.04 s / 0.04 s |

Unread caches matched the entry table in every case, including lists under 6 IDs and mark-unread. A production instance (PostgreSQL about 100 ms away) has been running the PostgreSQL variant of this change. Reeder on iOS, which had been timing out on every sync, now syncs normally, and `edit-tag` requests finish in under a second.

* SQLite, PostgreSQL: batch markRead for lists of IDs

FreshRSS_EntryDAOSQLite::markRead() handled an array of IDs one entry
per transaction, and FreshRSS_EntryDAOPGSQL inherits it. Delegate
arrays to FreshRSS_EntryDAO::markRead(), whose batched
UPDATE ... WHERE is_read<>? AND id IN (...) is portable, is chunked by
MAX_VARIABLE_NUMBER, and calls back into the per-entry path for small
lists.

Fix https://github.com/FreshRSS/FreshRSS/issues/9574

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Reduce comments

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-17 09:28:55 +01:00
Ricardo Simões d614912f3c Update pt-PT translation (#9573)
Updates European Portuguese pt-PT translation
2026-11-17 08:15:12 +01:00
Corey QuinnandAlexandre Alapetite e7fe44bf86 PostgreSQL: detect FreshRSS tables by visibility rather than owner (#9535)
* PostgreSQL: the owner was never the story, so stop asking who owns the tables

For as long as the install check has existed, it asked pg_tables who owned
the tables and compared that against the database login. Nobody asked why.
The login is a gateway user, the tables belong to whatever role ran the
install, and whenever those two names diverged the check reported the schema
as missing. Visibility was the question all along.

tablesAreCorrect() now asks pg_class which ordinary and partitioned tables
are visible on the search_path. If PostgreSQL can see it, it counts. A table
parked in a schema outside the path does not hide a missing one, and a view
named like a table is not a table.

The new test builds a role, a visible schema, a hidden schema, and a view
with a suspicious name, then checks that each answer is the true one. It runs
against a real PostgreSQL 18 service in CI. Locally it skips unless
FRESHRSS_TEST_PGSQL_DSN is set.

* Pin the CI Postgres service to a digest, because somebody moved the tag

For the record: nobody announced it. The postgres:18-alpine tag sat in
tests.yml like a loaded gun pointed at every CI run, and zizmor was the
first thing to notice it had no fixed identity at all. Remember the
Denver Airport. Remember that tags are not promises.

This commit replaces the mutable tag with the exact multi-arch digest the
suite was already tested against:

  postgres:18-alpine@sha256:eaef288f54a90a909e49f0121d5d047a5e974e922699de4249625cf7cde34f36

This is not a version bump. Same image, same PostgreSQL 18, same Alpine
base. The only thing that changed is that the image can no longer be
swapped out from under us between Tuesday's green run and Thursday's
mystery failure.

Verification: all pre-commit PHP, test, JS, CSS and Markdown checks pass.
Local pedantic offline zizmor reports no findings. This resolves the
unpinned-service-image blocker on PR #9535.

* Rewrite test a bit

* Fix make test-all

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-16 23:26:18 +01:00
Inverle 77e74e81b7 Serve consistent error responses on failed logins (#9568)
Fixes #4095

Follow-up of #9566

Although no separate error message for disabled users yet (will be done in another PR).
2026-11-16 22:38:25 +01:00
Inverle 06c0329de2 Fix wrong status code on failed login (#9566)
Regression from https://github.com/FreshRSS/FreshRSS/pull/9358 (PR not present in current release, stopped sending 403 on failed logins).

This PR fixes the Minz bug mentioned in https://github.com/FreshRSS/FreshRSS/pull/9358#discussion_r4382254359 which occurred with `redirect: false` redirects.

But it also takes a different approach for redirecting, by using HTML instead of the `Location` header (to address one additional issue with a resubmit prompt appearing when refreshing the login page after a failed login).

403 is now returned during failed reauthentication as well.
2026-11-15 23:34:53 +01:00
Artem Netsvetaev 62c47b7168 Fix lookup of the localised default category (#9543)
The GReader API exposes a translated default category name while the database stores Uncategorized. Resolve that name by the constant category ID so marking the category as read accepts the label returned by the API.

Add SQLite regression coverage for English, Russian and French, ordinary Cyrillic category names with spaces, and missing categories.

Fixes #9542
2026-11-14 22:31:20 +01:00
d1fe6e694d Add option to open articles on their original website (#9554)
* Add option to open articles on their original website

Clicking an article title can now open the original website instead of the article in FreshRSS. The link icon then opens the article in FreshRSS.

fix https://github.com/FreshRSS/FreshRSS/issues/1954

* i18n: fr

---------

Co-authored-by: Eduardo Coronell <eduardo.coronell@aspsols.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-14 22:30:32 +01:00
Alexandre Alapetite e66fa341a0 Better catch and log user regex errors (#9559)
To get a chance to find out where they come from:

New log:
```
[Thu, 12 Nov 2026 15:28:27 +0000] [warning] --- FreshRSS_Entry::regexMatch Invalid PCRE regex `/\q/`; preg_match(): Compilation failed: unrecognized character follows \ at offset 1; in search: `intitle:/\q/ author:Alice`; first triggered by entry 1731000000123456 of feed 123
```

instead of:
```
PHP Warning:  preg_match(): Compilation failed: unrecognized character follows \ at offset 1 in /var/www/FreshRSS/app/Models/Entry.php on line 875
```
2026-11-14 21:46:31 +01:00
Carl df1953f8d3 Load theme icons in views rendered without layout (#9564)
The theme was only loaded by the layout, so AJAX-loaded views such as the feed and category settings panels fell back to the default icons.
2026-11-14 11:10:28 +01:00
Jay HemnaniandAlexandre Alapetite 2ce6f1125b fix: do not double-encode titles and authors when importing JSON (#9556)
* fix: do not double-encode titles and authors when importing JSON

FreshRSS exports titles and authors HTML-encoded, and the JSON import
encoded them again since #9168, so restoring a ZIP export turned
"Post &amp; more" into "Post &amp;amp; more". Decode before encoding.

* Unit test

* Reduce comments

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-12 17:39:51 +01:00
Alexandre Alapetite 02aaa56aca Fix OPML import of numeric-string category names (#9552)
fix https://github.com/FreshRSS/FreshRSS/issues/9551
`array_merge()` changes the key value of numeric-string keys
2026-11-11 21:43:25 +01:00
CaoMeiYouRenandAlexandre Alapetite 8e281292f9 RSS: emit <enclosure> for BitTorrent attachments (#9553)
* feat: add the <enclosure/> field to enhance compatibility with BitTorrent downloaders

Closes #6227

Changes proposed in this pull request:

- Emit an additional RSS 2.0 `<enclosure>` element for BitTorrent attachments in the
  generated RSS output (`p/api/query.php?...&f=rss` and the per-feed RSS view).
  The existing `<media:content>` output is unchanged.
- Emit it only for `application/x-bittorrent`, `magnet:` and `.torrent` URLs, and skip
  images / audio / video. Since 1.24 thumbnails are prepended to the enclosure list, a
  naive implementation would duplicate cover images (and podcast media) as attachments.
- Always set `type="application/x-bittorrent"`, and copy `length` when the feed provides it.
- Add unit tests in `tests/app/Views/rssViewTest.php`: torrent, magnet without type,
  image attachment skipped.

* fix(rss): emit <enclosure> only for BitTorrent attachments

The previous patch emitted <enclosure> for every enclosure. Since FreshRSS
1.24, thumbnails are prepended to the enclosures list, so cover images and
podcast audio were also duplicated as RSS attachments. Emit the tag only for
application/x-bittorrent, magnet: or .torrent URLs, and always set
type="application/x-bittorrent" so clients such as qBittorrent can use it.

Add three rssViewTest cases: torrent, magnet without type, image skipped.

* Improve regex

* Minor whitespace

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-11 21:02:30 +01:00
InverleandAlexandre Alapetite 6af8ebcbff Fix current password requirement during password changes (#9550)
* Fix current password requirement during password changes

Regression from #9358 (follow-up, PR not present in a stable/versioned release)

Fix [GHSA-5vxm-62pg-frff](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-5vxm-62pg-frff)

* Remove stale client side bcrypt comment from passwordUtil

* docs: PHP 8.1 is no longer supported

* Minor typographic preference

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-10 01:13:52 +01:00
Mehmet 27c2b18822 Shared queries: keep user search in HTML pagination (#9545)
Fix the paging bug noticed in #9544.

In the HTML view of a shared user query, the pagination links did not include the `search` parameter, so the user search was lost when going to the next page.

The pagination links now keep the user search (URL-encoded). The common part of the URLs is factored out, using `&amp;` consistently.

Tested locally with a shared query of 60 entries and `search=x`: the second page now only shows matching entries.
2026-11-09 08:47:37 +01:00
6d7417ad8b Validate CURLOPT_PROXY format in sanitizeCurlParams() (#9537)
* Validate CURLOPT_PROXY format to prevent SSRF allowlist bypass

sanitizeCurlParams() previously only whitelisted cURL option keys and
never validated the CURLOPT_PROXY value itself. httpGet() and the
SimplePie File constructor both strip a scheme from the proxy string
with a greedy preg_replace('#^.*://#', '', $proxy) before running the
host through the internal-host allowlist / DNS-pinning check, but the
*original*, unstripped value is what actually gets handed to cURL.

A proxy value containing a second "://", e.g.
http://127.0.0.1:8080/://8.8.8.8, is reduced by the greedy strip to
the trailing "decoy" host (8.8.8.8) for the allowlist check, while
cURL still connects using the full original string. Depending on how
the installed libcurl parses it, this can route the request to
127.0.0.1:8080 instead of the validated public address.

This adds isSafeProxyString(), a strict format check for
[scheme://][user[:pass]@]host[:port] with no extra path, query,
fragment, or embedded scheme separator, and rejects CURLOPT_PROXY in
sanitizeCurlParams() when it doesn't match. Since every per-feed and
OPML-imported curl_params array is routed through sanitizeCurlParams()
before use (Feed.php, SimplePieCustom.php, ImportService.php), this
single chokepoint covers both the httpGet() and SimplePie fetch paths.

Added regression tests in httpUtilTest.php covering the exploit
payload and a range of legitimate proxy strings (bare host:port,
scheme-prefixed, SOCKS5 with credentials, SOCKS5h host-only).

* Normalise CURLOPT_PROXY scheme once, centrally; drop redundant downstream strips

Per review feedback: now that sanitizeCurlParams() validates CURLOPT_PROXY
and guarantees at most one scheme separator, it also strips that (validated)
scheme once, so the value stored is always scheme-less. This removes the
need for httpGet() and the bundled SimplePie File::curlInit() to each
re-strip the scheme themselves -- both call sites are updated to rely on
the value already being normalised.

Updated the regression tests to assert the normalised value, not just
whether the key survives sanitization.

* Disallow a scheme in CURLOPT_PROXY entirely, per review

CURLOPT_PROXYTYPE is what tells cURL the proxy's scheme -- CURLOPT_PROXY
itself was never supposed to carry one. Rather than validating-then-
stripping a scheme, sanitizeCurlParams() now rejects any CURLOPT_PROXY
value that contains one at all, simplifying isSafeProxyString() and
removing the normalisation step (and its own small regex) entirely.

Trimmed the accompanying comment to the one load-bearing line, and
updated the stale 'strips the scheme' wording in httpGet() and the
SimplePie File::curlInit() comment to 'rejects a scheme-containing
value', matching the simpler behaviour. Updated the regression tests
to match: a scheme-containing value (even a well-formed one) is now
rejected outright instead of being normalised.

* Sync SimplePie
https://github.com/FreshRSS/simplepie/pull/95

* Simplify CURLOPT_PROXY validation to a single str_contains('/') check

Per review (AI-assisted, credited to Inverle): a regex was more than this
needs and had a regression -- it rejected valid IPv6 proxies like [::1]:8080
because their host part contains multiple colons. A proxy value never
legitimately contains a "/": that single check still rejects a scheme
(scheme:// always contains "/") and the original exploit payload, and
additionally blocks a SOCKS Unix-domain-socket path such as
localhost:9050/path/to.sock -- cURL treats that specially for SOCKS
proxies and ignores the port, so an allowlisted host:port could otherwise
be smuggled into connecting to an arbitrary local socket.

Also bumped the vendored SimplePie commit in lib/composer.json now that
the companion fix (FreshRSS/simplepie#95) is merged, and added test
cases for the IPv6 and Unix-socket scenarios.

* Reduce comments

---------

Co-authored-by: S31ZUR3 <191032395+S31ZUR3@users.noreply.github.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-09 08:43:08 +01:00
669997ecbe Use a keyed hash for favicon cache keys (#9518)
* Use keyed hash (HMAC-SHA256) for favicon cache keys

The favicon cache key was a CRC-32 checksum of the salt-prefixed feed
website URL (or feed icon URL). CRC-32 is linear, so collisions for
equal-length inputs are independent of the salt prefix: a user could
compute offline a website URL for their own feed colliding into
another feed's cache slot, overwrite the shared
data/favicons/<hash>.txt, and have the unauthenticated public favicon
endpoint fetch and serve their image to every user of the instance.

Replace the checksum with a keyed hash (HMAC-SHA256, instance salt as
key, truncated to 16 hex chars) so the cache key cannot be forged
without the secret salt.

* Preserve legacy custom favicons when upgrading cache keys

* Base64 hash (shorter) and native copy

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Co-authored-by: Inverle <inverle@proton.me>
2026-11-08 20:43:53 +01:00
Mehmet 4ec877d299 Search: quote parentheses and OR when serialising terms (#9541)
`FreshRSS_Search::__toString()` did not quote values containing parentheses or the `OR` keyword, so serialising a parsed search and parsing it again could change its structure (e.g. `"a(b"` was serialised as `a(b`).

   This makes the serialisation lossless for such values, and adds tests, including a round-trip test (parse → toString → parse).
2026-11-08 15:47:15 +01:00
IEEE-754 69f715670f i18n: Improve Traditional Chinese translations (#9540)
- Refine wording
- Fix incorrect translation
- Add some new translations
2026-11-07 19:07:54 +01:00
spa77k b8a738ec12 Add filter preview button to label configuration (#9538)
Closes #9533

- The label configuration panel (`app/views/helpers/tag/update.phtml`) had no "Preview filters on existing articles (new window)" button, unlike the feed, category and global reading settings (the button was added in #7959).
- Add the same button below the auto-labelling filter textarea (`filteractions_label`). It uses the generic `configure/viewFilter` action, as in the global settings, with `filters_name=filteractions_label`.
- Label actions are not scoped to a feed or category: `feedController::applyLabelActions` matches the filter against all new articles. So the generic version, which does not restrict the search with `c:` or `f:`, is the appropriate one.
- The existing translation key `sub.feed.filteractions.view_filter` is reused, so no new translation is needed.
2026-11-06 17:51:25 +01:00
i @manandAlexandre Alapetite 4e8a258b01 Support choosing the sort type when creating or editing a user query (#8954)
* Support choosing the sort type when creating or editing a user query

Changes
- User queries can now store a sort field (sort type), not only the sort
  direction. The create and edit forms expose a single combined dropdown
  (field + direction) that reuses the existing `index.menu.sort.*` options,
  matching the global reading-settings sort UI.
- The "Bookmark current query" action now also remembers the current sort
  field, where it previously kept only the order direction.
- Relabel the query sort control from "Sort by date" to "Sort by"; other
  languages are marked for re-translation (// TODO).
- Add a CHANGELOG entry and credit the contributor in CREDITS.

Implementation
- `FreshRSS_UserQuery`: add an optional `sort` property mirroring `order`
  (constructor parsing, `toArray()`, `getSort()` falling back to the user
  default sort, and a `hasParameters()` check).
- `configureController`: split the combined dropdown value into `sort` and
  `order`, validating the field against the implemented sort types
  (`id`, `c.name`, `date`, `f.name`, `length`, `link`, `title`, `rand`);
  separate `sort`/`order` request parameters are still accepted so the
  "bookmark current query" flow keeps working.
- Views render the combined dropdown and persist `sort` as a hidden field.
- `p/api/query.php`: back-fill `sort` from the saved query when the request
  does not provide one, mirroring the existing `order` handling.
- Add unit tests covering the sort round-trip and `toArray()` inclusion.

Compatibility
- No database or schema change: user queries are stored in the per-user PHP
  config array, which keeps arbitrary keys verbatim, so no migration is
  required.
- Upgrade: existing queries without `sort` fall back to the user default
  sort; behaviour is unchanged until a sort is explicitly chosen.
- Downgrade: older versions ignore the extra `sort` key and keep working;
  re-saving under an old version simply drops the key with no data loss.
- Shared query URLs without a `sort` parameter remain valid.

* Refresh README translation statistics

* i18n: fr

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-02 21:43:05 +01:00
Jgolding1998 d03296f074 Add current English text to DIRTY translation comments (#9525)
* Add English references to DIRTY translation comments

Translators currently have to find the English source separately for each `// DIRTY` entry. The translation formatter now appends it on the same line, including English plural fallback for languages with additional plural forms. It keeps hints on one safe PHP comment line and refreshes them when English changes.

Only comments change in the locale files; translation values and plural rules are unchanged. Single-form translations show both English forms as `Singular: … | Plural: …`. Generated README contribution links match bare and annotated TODO/DIRTY markers and retain the end-of-line anchor.

Closes #9463.

* Show both English forms for single-form translations
2026-11-02 21:25:34 +01:00
Alexandre Alapetite 6a640623d1 Fix more overlapping search replacements (#9524)
Follow-up of https://github.com/FreshRSS/FreshRSS/pull/9484
The proposed construct is good enough compared to the previous TODO suggesting `PREG_OFFSET_CAPTURE`
2026-11-02 15:46:56 +01:00
73b47af405 Fix overlapping saved search references (#9484)
Match the longest saved query reference before shorter references so
expansion does not depend on their order. Apply the same replacement
behaviour when preserving unexpanded searches, including negated ones.

Add regression coverage for overlapping IDs, names, and ID groups.

Refs #9483

Co-authored-by: Busy-SweetPotato <346315145+Busy-SweetPotato@users.noreply.github.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-01 21:56:10 +01:00
PhilipandInverle 9e87fcfb3e Esc leaves the search box (#9462)
* feat(shortcuts): Esc leaves the search box

Pressing Esc while focused in the search box now blurs it, so the user can immediately resume navigating articles with the keyboard instead of staying trapped in the input. Closes #5043.

* Add Hellraiser28 to CREDITS.md

* Drop IE11 key handling, make the header search a text input

* Update p/scripts/main.js

Co-authored-by: Inverle <inverle@proton.me>
2026-11-01 15:26:28 +01:00
Nikolai ShcheglovandAlexandre Alapetite acde1bfbf5 Fix non-ASCII characters in scripts of fetched HTML pages (#9384)
* Fix non-ASCII characters in scripts of fetched HTML pages

To add a <base> to a fetched HTML page, enforceHtmlBase() re-serialises it
with libxml2 saveHTML(). For a whole document, libxml2 2.9 only knows the
charset from <meta http-equiv="Content-Type">: with <meta charset="UTF-8">
or a byte order mark, it writes every non-ASCII character as an HTML entity.
In text that is harmless, but inside <script> entities are not decoded, so
e.g. the JSON read by HTML + XPath + JSON feeds gets "Wall Street&rsquo;s"
instead of "Wall Street’s", which then shows in titles.

UTF-8 documents are now serialised node by node, which writes UTF-8.
Other charsets keep the previous output.

* Clarify comment about the byte order mark

* Remove comment about the byte order mark

* Minor test syntax preference

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-10-31 14:48:37 +01:00
2ebfff6e7d Add feeds_after_actualize hook (#9438)
Extensions that process new articles in bulk (summaries, exports,
notifications) have no way to react to the end of a refresh:
freshrss_user_maintenance runs before the feeds are fetched, and new
articles stay in the temporary table until the whole loop is done.

The new FeedsAfterActualize hook runs once the new articles are
committed, with the refreshed feeds whose articles changed and the
number of new articles: after a cron or web refresh (actualizeAction,
including the commit-only request of the web interface) and after
actualizeFeedsAndCommit (CLI, API, WebSub, feed added).

Co-authored-by: ChrisB85 <792899+ChrisB85@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 11:38:49 +01:00
Alexandre Alapetite d4964dc1ff WebSub: Implement support for hub.secret (#9430)
* WebSub: Implement support for hub.secret
https://www.w3.org/TR/websub/#signing-content
Fix https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-498g-vgpq-mr66
`hub.secret` is optional, but improves security.
Reported by @Atharros

* hub.secret SHOULD only be specified when the request was made over HTTPS

* Minor whitespace

* Add legacy support
2026-10-30 22:25:33 +01:00
InverleandAlexandre Alapetite 76e8993579 Replace bcrypt challenge auth with direct password comparison (#9358)
* Replace bcrypt challenge auth with direct password comparison

Closes #2428

Highlights:

* Replaced the bcrypt challenge authentication flow with direct password comparison against the bcrypt hash stored in the user configuration.
  * Removed the `bcrypt.js` dependency, so authentication no longer depends on JavaScript.
  * Removed the nonce and challenge mechanism and the `nonce` endpoint from the `javascript` controller.
  * Removed the JavaScript and HTML code used for the previous authentication flow.
  * Removed the `<noscript>` blocks that were only needed for the previous authentication flow.
* Updated `FreshRSS_FormAuth::checkCredentials()` to accept the username, stored bcrypt hash, and plain-text password directly.
  * The stored password hash must still use the expected bcrypt format.
  * Empty or whitespace-only passwords are rejected even if the hash would otherwise match.
  * The bcrypt 72-byte limit is enforced during normal authentication.
  * Existing bcrypt passwords are handled correctly when the 72-byte limit cuts through a UTF-8 character.
  * Password input is no longer trimmed before authentication or password changes. Leading and trailing whitespace is therefore kept as part of the password.
* Added `FreshRSS_FormAuth::passwordRequirementsMet()` to replace `FreshRSS_password_Util::check()`.
  * New passwords must be between 7 and 72 bytes by default.
  * The minimum length check can be disabled where needed.
  * Password requirements are now checked server-side for all password creation and update paths.
* Added client-side byte-length validation for password fields using `TextEncoder` and `data-max-bytes`.
  * This gives better feedback for UTF-8 passwords.
  * Server-side validation remains authoritative.
* Updated password handling in authentication, re-authentication, self-deletion, user creation, and user update paths so passwords are not trimmed automatically.
* Added `FormAuthTest` to cover:
  * password length limits in bytes
  * UTF-8 passwords around the 72-byte limit
  * bcrypt truncation behavior during authentication
  * malformed and non-bcrypt hashes
  * empty passwords
  * authentication failures and log messages
* Removed `bcrypt.js` from the documented dependencies and updated the authentication documentation.
* Updated the installation and authentication views and JavaScript to match the new password handling.

This simplifies the authentication flow, removes the client-side bcrypt challenge, makes password validation consistent between the client and server, and adds more test coverage while keeping compatibility with existing bcrypt password hashes.

Because the password is now sent directly to the server instead of being processed by `bcrypt.js`, deployments should use HTTPS. Documentation for HTTPS setup can be handled separately.

* Add test case with password truncated down to 71 characters

* Compare log messages too during form auth tests

* Mark the `getLastLog()` method as impure

* Fix: Check password reqs against new password instead of current

* Fix: Add custom JS validator for UTF-8, handle cut-off UTF-8 during login

* Fix: Enforce password requirements everywhere server-side

* Add TODO for updateUser in CLI

* make readme

* Fix extra.js in install.php

* Don't report validity yet if the password is too short or not filled out

* Simplify checking of whether to report validity

* Fix: Do not trim password from user's input

* Also `trim: false` in some userController paths

* Use the proper argument order for PHPUnit's `assertSame()`

* Remove `maxlength` in favor of `data-max-bytes`

But add `pattern` again for some nojs support

* make readme

* composer run-script translations

* Update i18n string for web form admin setting

* i18n: fr

* Minor whitespace

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-10-30 22:21:26 +01:00
Alexandre Alapetite fd3f75b3a2 Require PHP 8.2+ (#9470)
Drop PHP 8.1 (EOL December 2025), drop Ubuntu 22.04 (EOL May 2027, and there is now 24.04 and 26.04 LTS).
PHP 8.1 is already EOL, and Debian, Alpine, Fedora, Red Hat, Synology have dropped PHP 8.1 already.
See https://github.com/FreshRSS/FreshRSS/discussions/5474#discussioncomment-16791937

With PHP 8.6 around the corner and in particular a relevant `FILTER_FLAG_GLOBAL_RANGE` in PHP 8.2+.
* https://www.php.net/releases/8.2
* https://www.php.net/filter.constants.validation#constant.filter-flag-global-range
* https://www.php.net/class.sensitiveparameter
* https://php.watch/versions/8.2/readonly-classes
* https://www.php.net/function.ini-parse-quantity

Allows updating to PHPUnit 11.x instead of 10.x
https://phpunit.de/supported-versions.html

Contributes to https://github.com/FreshRSS/FreshRSS/issues/9475

* Add regression test for FILTER_FLAG_GLOBAL_RANGE
https://github.com/FreshRSS/FreshRSS/pull/9470#discussion_r4371168720
2026-10-26 21:02:32 +01:00
Frans de JongeandAlexandre Alapetite 54391ce1fb Fix Retry-After cache when proxy is used (#9508)
* Fix Retry-After cache when proxy is used

Because of #8029 and #8218, a proxy would never apply Retry-After.

Possibly related to the problem described in <https://github.com/FreshRSS/FreshRSS/pull/7760#issuecomment-6395796130> by @DamonHD.

* work around line length 168 instead of 165

* Update app/Models/Feed.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-10-26 20:44:26 +01:00
Shaurya Kesarwani 931fb41640 Keep JSON feed attachments as enclosures (#9510)
convertJsonToRss() collected item attachments into
$rssItem['attachments'], but FreshRSS_Entry::fromArray() ignores that
key, so attachments from JSON Feed and JSON dot notation feeds never
reached the generated RSS and were lost. Store them in the entry's
`enclosures` attribute instead, HTML-escaped like the other fields.

- Attachments of JSON Feed and JSON dot notation feeds (`itemAttachment`, `itemAttachmentUrl`, `itemAttachmentType`, `itemAttachmentLength`) were collected by `convertJsonToRss()` into `$rssItem['attachments']`, but `FreshRSS_Entry::fromArray()` never reads that key. So the generated RSS had no `<media:content>` for them and the enclosures were silently dropped. For example, a JSON Feed podcast item with `"attachments": [{"url": "https://example.net/1.mp3", "mime_type": "audio/mpeg"}]` showed up without its audio file.
- The attachments are now stored in the entry's `enclosures` attribute, which is what `rss.phtml` renders. The URL and type are HTML-escaped like the other fields, the length is kept only when numeric, and attachments without a URL are skipped.
- Unit test converting a JSON item with an attachment whose URL contains `&`, asserting the `<media:content url="…&amp;…" type="audio/mpeg" length="1234">` element and valid XML. It fails without the fix.
2026-10-26 08:47:23 +01:00
Pythame bc962e9aad fix: escape labels during JSON import and render tag dropdown as text (#9504)
- Normalize label names parsed from Google Reader JSON categories during import, using the same escaping helper as the other imported string fields.
- Decode stored label names before returning them to the dynamic tag dropdown.
- Build dynamic tag dropdown entries with DOM text nodes instead of HTML string concatenation.
2026-10-25 11:48:58 +01:00