Repository navigation
Conversation
set_cookies_method(req, false) means "only touch preferences named in the query string", and the PREFS loop honours that via the remove_cookies flag. The subscriptions and filters else-branches did not, so any /settings/update request (e.g. the "Enable HLS" link, ?use_hls=on) emitted deletion cookies for subscriptions and filters and silently wiped the user's lists. Gate both else branches on remove_cookies. /settings/restore still passes true and keeps clearing absent cookies; POST /settings is a separate handler and is unchanged. Fixes redlib-org#562
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
/settings/update(the "quick update one preference" endpoint) silently deletes the user'ssubscriptionsandfilterscookies on every call, unless those two fields happen to be in the query string. Clicking Enable HLS (?use_hls=on), disable this notification (?hide_hls_notification=on) or the NSFW bypass this gate link (?show_nsfw=on) wipes the whole subscription list with no warning.Root cause
src/settings.rs,set_cookies_method(req, remove_cookies).update()passesfalse("don't clear settings that were not passed"),restore()passestrue. ThePREFSloop honours the flag:but the
subscriptionsandfiltersblocks below it did not — theirelsebranches calledremove_cookie(...)unconditionally (and thewhileloops inside those branches removed the numberedsubscriptionsN/filtersNcookies unconditionally too). This PR gates both wholeelseblocks on the existing flag, which covers the unnumbered and numbered deletion calls with two one-line changes.POST /settingsis a separate handler (settings::set) and is untouched./settings/restorestill passestrue, so it keeps clearing absent cookies.Verification
Method: execution. A full
cargo buildof redlib was not feasible here (it pullswreq→boring-sys2, building BoringSSL from source, on aarch64, inside a tight maintenance window). Instead I compiled a small harness thatinclude!s the verbatimset_cookies_methodbody extracted from this file (sed -n '103,264p'), plus the realResponseExt::insert_cookie/remove_cookieandjoin_until_size_limit, against the realcookie/url/timecrates. Only the HTTP transport types are substituted withhttp::Request/http::Response; the cookie logic under test is byte-for-byte the repo source (basea4d36e954cf1bd64f209cd8868c5a29edc81b374).Before (
main, base SHA) —Cookie: subscriptions=selfhosted+Fedora+linux; filters=spam:Same for
?show_nsfw=onand?hide_hls_notification=on.After (this branch) — identical input:
No
subscriptions=/filters=deletion, including when numberedsubscriptions1/filters1cookies are present in the request.Regressions checked (after):
/settings/restore(remove_cookies = true), subs/filters absent → still emitssubscriptions=,subscriptions1=,filters=,filters1=deletions. ✅/settings/updatewithsubscriptions=linux&filters=spamin the query → still sets them and cleans up stale numbered cookies. ✅rustfmt --edition 2021 --check src/settings.rspasses (matches the repo'scargo fmt --all -- --checkCI job).Not verified: the change was not exercised against a running redlib server binary (build infeasible here); the harness executes the exact function source, not the assembled HTTP server.
Fixes #562