Commit Graph
108 Commits
Author SHA1 Message Date
0abfe20385 Fix: corriger les statistiques PostgreSQL (#9659)
Closes #9658

Changes proposed in this pull request:

- Use PostgreSQL `dow` instead of `day` for the day-of-week chart.
- Normalize month repartitions to exactly 12 entries, from January to December.
- Include today in the 30-day chart, anchor the day calculation on the oldest timestamp so integer division is always positive, and return a JSON list.
- Set chart labels and build the average line as an array matching the bar data.

* Fix: corriger les statistiques PostgreSQL

* Remove dead code

---------

Co-authored-by: upskaling <upskaling@users.noreply.github.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-11-30 20:35:11 +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 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
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 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
RaedandRaed 60e477423f Fix TypeError from entry IDs on 32-bit platforms (#9578)
An integer literal above PHP_INT_MAX is a float on x86, and _id() only
accepted int|string, so the export test failed there with "must be of type
string|int, float given".

* Build entry IDs as strings in the tests

1700000000000000 + $i is a float on 32-bit platforms, where it exceeds
PHP_INT_MAX, and FreshRSS_Entry::_id() rejects it. Entry IDs are strings
everywhere else, since uTimeString() and the DAO layer both produce
numeric strings, so keep the ID a string in the test instead of accepting
a float. A test now pins that contract.

Refs #9569

---------

Co-authored-by: Raed <Raed2180416@users.noreply.github.com>
2026-11-18 12:52:00 +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
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
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
Mehmet 931a6b3bbd Shared queries: combine user search structurally (#9544)
Follow-up to #9541.

In `p/api/query.php`, the optional `search` parameter of a shared user query was appended as a string to the user query's own search, and the result was parsed again.

This keeps both searches as parsed objects and combines them with a structural AND via `FreshRSS_BooleanSearch::add()`, avoiding the serialise/re-parse round trip. Adds a test for combining Boolean searches with `add()`.
2026-11-08 22:47:48 +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
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
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
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
0187b15c8e Sanitizer: block data: URI scheme while keeping data:image for images (#9417)
* Sanitizer: block data: URI scheme, keep data:image for images

FreshRSS_SimplePieCustom only disallowed the `javascript` scheme, so
`data:text/html,...` URIs in feed content survived
sanitization on <a href>, <iframe src>, <audio|video|source|track src>.
The default CSP neutralises these on FreshRSS pages, but clients and
deployments without that CSP (API WebViews, extensions using amendCsp(),
proxies stripping headers) could execute them. Same class as
GHSA-3fw6-j8m4-82vj / #9272.

- Sanitize::is_allowed_uri(): element/attribute-aware check that still
  permits inert `data:image/...` on img[src], image[src], video[poster]
  while blocking `data:` elsewhere; replace_urls() now uses it.
  is_allowed_scheme() is unchanged for backward compatibility.
- SimplePieCustom: disallow_uri_schemes(['javascript','data']).
- Tests: 4 blocked-input cases, a data:image keep-alive test and an
  `unsafe:` prefix test. They fail without the patch and pass with it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

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

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-10-11 20:36:09 +02:00
Nikolai ShcheglovandAlexandre Alapetite f65d2760e3 Fix domain-wide Retry-After (#9390)
* Fix domain-wide Retry-After

- Fix the domain-wide HTTP `Retry-After` for public servers, which has not applied since #8195 (FreshRSS 1.28.0).
  - `getRetryAfterFile()` passed the bare host name to `Minz_Request::serverIsPublic()`. That function expects a URL, so it always returned `false`.
  - So a 429 or 503 paused only the URL that got it, despite the log saying "For that domain, will first retry after …", and FreshRSS went on requesting the other feeds of that server. With several Reddit feeds, for instance, each one got its own 429 in turn.
  - `serverIsPublic()` now gets the URL. Its answer is kept per host for the rest of the request, because it resolves the host name (`dns_get_record()`), and a refresh may load many feeds of the same host.
- Fix the per-URL `Retry-After` of servers on a local network (#8195), which never applied to feeds whose URL, as stored, differs from the URL as requested.
  - Stored URLs are HTML-encoded, e.g. `&amp;` in an RSS-Bridge URL, and may end with `#force_feed`.
  - `FreshRSS_Feed::load()` checked the stored URL, while the pause is stored for the URL as requested. It now checks the requested URL, as `loadJson()` and `loadHtmlXpath()` already do.

* Minor final

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-10-03 10:22:47 +02:00
Morax cc45db5ef8 Fix adaptive reading state after marking articles read (#9290)
Closes #9288

Changes proposed in this pull request:

The mark-as-read links contain the resolved state, so the automatic reading preference becomes an explicit `state=2` filter after the redirect. Once the last unread article is marked read, the page stays empty instead of showing all articles.

- Keep the requested state separately from the resolved state used by the action. A redirect state of `0` reapplies the reading preference; explicit filters still survive the redirect as intended by #9007.
- Carry that value through the menu, footer and “Load more” link. This matters with oldest-first pagination, where the last footer supplies the menu button's action.
- Add request-state and rendered-pagination tests, plus a changelog entry.

How to test the feature manually:

1. With both read and unread articles, choose “Show unreads if any, all articles otherwise”. Mark all as read from the footer, then repeat using the top button. The resulting page should show the read articles.
2. Set one article per page and oldest-first sorting. Load the remaining articles before marking all as read; the same fallback should work.
3. Select an explicit unread filter: marking everything read should still leave an empty unread view. Also check a favourite filter with a search term, including “Mark selection unread”; the search and favourite scope should remain intact.

Validation: `make NO_DOCKER=1 fix-all` and `make NO_DOCKER=1 test-all` pass with PHP 8.5.9 (719 PHPUnit tests, 1,378 assertions). Browser checks passed against SQLite in Chromium (desktop and mobile viewport) and Firefox. The original footer fails three of the six new rendered-pagination cases.
2026-09-11 08:18:09 +02:00
Alexandre Alapetite 61d7925af1 Config + increase default values for search max length and depth (#9280)
Fix https://github.com/FreshRSS/FreshRSS/discussions/9279
Follow-up of https://github.com/FreshRSS/FreshRSS/pull/9277

Values can be overridden in `data/config.php`, or in `./data/config.custom.php` before the install process
2026-09-10 22:14:55 +02:00
AdamKorczandAlexandre Alapetite dc5cf8221b Limit the length and parentheses nesting depth of a search query (#9277)
* Limit the length and parentheses nesting depth of a search query.

* Use exception

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-09-09 16:12:41 +02:00
Ali GündoğarandAlexandre Alapetite 18dfada959 Only allow http/https URI schemes for enclosure and thumbnail URLs (#9272)
* Only allow http/https URI schemes for enclosure and thumbnail URLs

Feed enclosure URLs were stored and rendered without URI scheme validation:
SimplePie's scheme check only applies to URLs inside content HTML
(Sanitize::replace_urls()), not to enclosure metadata, so a `javascript:`
URL survived the whole pipeline and was served as a clickable link in the
article view, including through the Google Reader compatible API.

Add FreshRSS_http_Util::isAllowedUrlScheme() and apply it:
- at store time, when building enclosure attributes in FreshRSS_Feed
- at render time, in FreshRSS_Entry::content(), so entries already stored
  in existing databases are protected as well

https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-3fw6-j8m4-82vj

* Reuse existing SimplePie is_remote_uri() function

* Use more realistic test examples

* Add tests for protocol relative
And simplify tests further

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-09-09 00:14:13 +02:00
Alexandre Alapetite f902047204 Offer to add a prefix when resharing user labels (#9236)
* Offer to add a prefix when resharing user labels
Improve https://github.com/FreshRSS/FreshRSS/pull/8112

* make fix-all
2026-08-28 08:51:57 +02:00
07c939d84f Fix: infinite recursion in sanitizeHTML() when maxLength truncation doesn't converge (#9043)
* Fix: infinite recursion in sanitizeHTML() when maxLength truncation doesn't converge

Sanitizing can grow a truncated HTML fragment (e.g. an unclosed tag gets
auto-closed), so the previous recursive shrink-and-retry could hit a fixed
point and recurse forever, crashing on a stack overflow. Bound the retries
and fall back to a hard truncation that always terminates.

Add unit tests for FreshRSS_SimplePieCustom::sanitizeHTML(), the XSS
sanitization applied to all untrusted feed content, which had no coverage.

* Update app/Models/SimplePieCustom.php

Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>

* Some refactoring
Avoid two mb_strcut in a row. More cases for fallback. Better fallback. More edge cases.

* Address trailing incomplete tag or entity

* Whitespace reduction

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
2026-08-28 08:47:04 +02:00
fa8e8a4400 Fix “mark as read older than…” widening the active search (#9173)
* Fix “mark as read older than…” widening the active search

Sibling searches of a `FreshRSS_BooleanSearch` are combined by OR, so
`prepend()` added the maximum publication date used by the “mark as read →
articles older than one day / one week” action as one more OR term instead of
an extra restriction.

With an active search and the stream sorted by publication date, that action
therefore marked as read every article older than the cut-off (ignoring the
search) plus every article matching the search at any date.

`prepend()` now wraps the existing expression first, reusing the logic that
`enforce()` already used for the same purpose.

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

* Fix SQL space

* Slight reduction of comments

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-08-04 22:09:12 +02:00
9b40f04f32 Fix tagging an already-tagged entry on PostgreSQL (#9136)
* Complete two source TODOs: negative UTC offset date parsing and PostgreSQL tag insert

_noDelimit() stripped '-' and ':' from the whole ISO 8601 string, including a
trailing UTC offset, so a negative offset such as "-05:00" silently lost its
sign and corrupted the parsed date. Extract a trailing offset (or "Z") before
stripping delimiters and re-append it unchanged.

FreshRSS_TagDAOPGSQL::sqlIgnore() returned an empty string as a placeholder,
so re-tagging an already-tagged entry produced a real SQL error on PostgreSQL
instead of being a silent no-op like on MySQL/SQLite. Replace the sqlIgnore()
keyword-injection approach with the sqlIgnoreConflict(string $sql): string
pattern already used by EntryDAO, and implement it for PostgreSQL with
"ON CONFLICT DO NOTHING".

Fixes #7923.

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

* Drop the negative-UTC-offset date fix, already covered by #9071

#9071 already fixes this exact bug in lib_date.php, so keeping this
PR focused on the PostgreSQL tag-insert fix only.

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

---------

Co-authored-by: Gerard Alvear <gerard.alvear@logiqd.me>
Co-authored-by: Claude <noreply@anthropic.com>
2026-07-23 13:52:09 +02:00
TowyTowyandClaude Fable 5 8c5bd58808 Fix SQL errors breaking regex search on MySQL / MariaDB (#9036)
On MySQL and MariaDB (the compressed content_bin code path,
isCompressed() === true), three of the four regex-search constructions
in FreshRSS_EntryDAO::sqlBooleanSearch() generated invalid SQL, so the
query failed and the search silently returned zero articles:

* intext:/regex/ appended a stray closing parenthesis after
  sqlRegex(...) (MySQL error 1248);
* -intext:/regex/ had the same stray parenthesis;
* -/regex/ emitted ' ANT NOT ' instead of ' AND NOT '
  (MySQL error 1064).

sqlRegex() already returns a self-contained, balanced expression
(REGEXP_LIKE(expr, ?, 'flags') or expr REGEXP ?), so no extra
parenthesis is needed, matching the uncompressed (SQLite / PostgreSQL)
branches.

The existing MySQL / MariaDB unit tests for intext:/regex/ had
captured the buggy unbalanced SQL as their expected strings; they are
corrected, and new cases are added for -intext:/regex/ and -/regex/
on both flavours.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 17:50:16 +02:00
Jam BalayaandAlexandre Alapetite 271257be42 Fix statistics repartition averages (#8996)
* Fix statistics repartition averages

* Minor code preference

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-07-07 10:42:53 +02:00
Alexandre Alapetite 542f4920e7 Fix lost elements while parsing search query (#8884)
Fix https://github.com/FreshRSS/FreshRSS/issues/8876
2026-05-24 20:23:58 +02:00
Alexandre Alapetite 1b90c40fd6 New automatic feed visibility/priority during search (#8609)
When the search query includes some feed IDs or category IDs, adjust feed visibility/priority filter to include at minimum feed or category visibility.
Fix: https://github.com/FreshRSS/FreshRSS/issues/8602
2026-03-21 17:15:07 +01:00
Alexandre Alapetite b68b80e5de Fix user query parsing (#8543)
* Fix user query parsing
Fix https://github.com/FreshRSS/FreshRSS/issues/8531
We used to take some shortcuts in the code, but now that the logic has complexified, we need to parse those user queries more properly.

* More fixes
2026-03-01 21:45:24 +01:00
Alexandre AlapetiteandInverle cf631b6f87 Implement filter on last modified date by server (#8131)
* Implement filter on last modified date by server
Especially relevant for API, to get the modified changes: the API will now return the articles that are new or which content has been modified since `ot`:

fix https://github.com/FreshRSS/FreshRSS/issues/7304
fix https://github.com/FreshRSS/FreshRSS/issues/2566
https://github.com/jocmp/capyreader/discussions/533#discussioncomment-11341808

New corresponding search operator `mdate:` and new UI:

<img width="650" height="627" alt="image" src="https://github.com/user-attachments/assets/8ba02937-abc7-44bf-b718-cf269cc37caf" />

* Migration from existing id column

* Fix auto-update

* Index after update for performance

* Minor comment

* Minor whitespace

* Fix regex

* Minor .gitignore

* Changelog and warning

* Update app/i18n/pl/gen.php

Co-authored-by: Inverle <inverle@proton.me>

* make fix-all

* Optimise SQL auto-update
For speed and resilience

* Minor SQLite change of sequence

* Changelog

* Speed optimisation: No DEFAULT 0

* Better migration

* Revert small bug

* Prepare filtering on multiple dates for API

* make fix-all

* Update tests

* Remaining manual merge

* Update versions

* Remove warnings no longer relevant in changelog

* Implement in API, and COALESCE

* No lastModified when adding new article

* Rework logic

* Sort IS NOT NULL

* Remove forgotten lastModified

---------

Co-authored-by: Inverle <inverle@proton.me>
2026-03-01 21:43:03 +01:00
Alexandre Alapetite d64a6c2751 Trim SQL whitespace before parenthesis (#8522) 2026-02-22 23:31:04 +01:00
Alexandre Alapetite 17be48fe1c Fix search expansion with backslash (#8497)
fix https://github.com/FreshRSS/FreshRSS/issues/8495
2026-02-16 23:14:04 +01:00
Alexandre Alapetite dae27ebd5d Fix wrong search toString in case of regex-looking string (#8479)
`author:'/u/Alice'` was missing its quotes during serialisation, transforming it to a regex.
2026-02-01 13:06:18 +01:00
Alexandre Alapetite 7573fee4f0 Fix MySQL transliterator_transliterate fallback (#8427)
The string syntax of `strtr()` cannot handle mutibytes characters, so need to be rewritten using an array map approach.
Extend the fallback replacements to include the Windows/ISO charsets of the latin languages for which we have a translation
2026-01-10 23:38:00 +01:00
Bartłomiej DmitrukandAlexandre Alapetite 26c1102567 Merge commit from fork
* Fix Path Traversal vulnerability in UserDAO methods

* Add tests and changelog for UserDAO path traversal fix

* make fix-all

* Fix PHPStan

---------

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2026-01-03 18:09:44 +01:00
Alexandre Alapetite 2527033057 Fix unwanted expansion of user queries in some cases (#8395)
fix https://github.com/FreshRSS/FreshRSS/issues/8378
2026-01-03 16:52:33 +01:00
Alexandre Alapetite 00c61cf34c Fix serialisation of dates in searches (#8341)
Dates should not be expanded/resolved in string serialisations of search expressions, as it otherwise break relative user queries such as `P30D`.
Fix of https://github.com/FreshRSS/FreshRSS/pull/8293
2025-12-24 01:19:06 +01:00
Alexandre Alapetite 6d57a9de47 Fix parsing of literal "or" in regex (#8338)
fix https://github.com/FreshRSS/FreshRSS/issues/7879
2025-12-23 11:58:51 +01:00
Alexandre Alapetite 00cd5df294 Use native PHP #[Deprecated] (#8325)
https://php.watch/versions/8.4/Deprecated
And enfore it with PHPUnit + PHPStan.
Especially useful for extensions.
2025-12-17 10:11:18 +01:00
Alexandre Alapetite 4bd5035914 Rework encoding of search filters (#8324)
Rework:
* https://github.com/FreshRSS/FreshRSS/pull/8222

now that we have:
* https://github.com/FreshRSS/FreshRSS/pull/8293

Follow-up of:
* https://github.com/FreshRSS/FreshRSS/pull/8311

* More simplification

* Deprecate getRawInput
2025-12-17 10:07:52 +01:00
Alexandre Alapetite a8a544a2a2 Fix search encoding and quoting (#8311)
Revised the encoding approach for searches: the HTML encoding is done just before its use for DB search.
Fix also some cases with wrong quoting.
Fix https://github.com/FreshRSS/FreshRSS/pull/8306#issuecomment-3643865439
Follow-up of https://github.com/FreshRSS/FreshRSS/pull/8293
2025-12-13 11:31:34 +01:00
Alexandre Alapetite 394411677e Add functions to modify a search expression (#8293)
* Allows easier modifications of the search expression.
* Add proper `__toString()` instead of just returning the raw input string. Allows in particular showing the result of the actual parsing of the raw input string in the UI.

Needed for https://github.com/FreshRSS/FreshRSS/pull/8294
2025-12-10 22:41:45 +01:00
Alexandre Alapetite 1282d3a270 PostgreSQL: compatibility with PCRE word boundary (#8141)
Allow the use of regex `\b` for word boundary (and `\B` for the opposite) even when using PostgreSQL.
Follow up of:
* https://github.com/FreshRSS/FreshRSS/pull/6706

For instance, `intitle:/\bnew\B/` will find *newest* but not *new* nor *renewal*.

Useful in particular to minimise the differences between PHP and database in:
* https://github.com/FreshRSS/FreshRSS/pull/7959
2025-10-22 21:21:17 +02:00
Alexandre Alapetite 7e72033859 Filter on last user modified (#8093)
Example: `userdate:PT1H` to select only articles modified by user during the last hour
Fix https://github.com/FreshRSS/FreshRSS/issues/4280#issuecomment-3393078024

Useful for instance to bulk mark as unread recently marked articles by error:
1. Click on the toggle button to show the read articles (making sure the toggle for the unread articles is off)
2. Sort by *User modified 9→1*
3. Filter by *user modified date*, for instance to the last 3 hours by typing `userdate:PT3H`
4. Click in the drop-down menu *Mark selection as unread*

P.S.: I have added at the same time a bunch of unit tests for date-related logic
2025-10-15 00:12:19 +02:00
Alexandre Alapetite e070c3ed2b Implement search form (#8103)
* Add UI for advanced search
To help users with the seach operators.
Obviously not as powerful as a manually-written search query.
Lack in particular negation and logical *and* for now, but I might try to do something about it.

<img width="939" height="1438" alt="image" src="https://github.com/user-attachments/assets/0bcad39b-eff3-4f44-876b-a2552af2af00" />

* Consistency: allow multiple user queries like S:1,2

* Fix user query and add tests
2025-10-15 00:08:40 +02:00