Description
The session-transfer flow does not reliably preserve client preferences. There are two independent problems in the current implementation:
- On HTTPS, the pad client stores preferences in
prefs, but the transfer UI reads only prefsHttp and the receiver always writes prefsHttp.
- The transfer UI reads the raw percent-encoded cookie value from
document.cookie. Passing that value to Express res.cookie() encodes the percent signs again. On the destination, js-cookie decodes once, leaving percent-encoded JSON that JSON.parse() cannot parse.
This is present on develop at f2cf95e06cd613fd0a06bbcb755e044c1dbfe306:
Steps to reproduce
- Open a pad over HTTPS and change a client preference such as theme/font/chat visibility.
- Create a session transfer from the settings dialog.
- Redeem the code in a different browser/device.
- Open a pad and inspect the transferred preferences.
The HTTPS source does not submit the prefs cookie. On HTTP, where prefsHttp exists, a typical JSON cookie such as %7B%22...%22%7D is submitted in encoded form and then encoded again when the destination cookie is written.
Actual behavior
Preferences are missing or unreadable after transfer; pad_cookie.ts falls back after its JSON.parse() failure.
Expected behavior
The destination should receive the same preferences for both HTTP and HTTPS deployments, encoded exactly once in the cookie format expected by js-cookie.
Possible direction
Transfer a decoded/validated preference object or JSON string rather than cookie wire bytes, select the source/destination cookie name according to the request protocol, and let one layer perform cookie encoding.
No plugins are required. I found this while benchmarking an automated code-review workflow and manually verified the current source and duplicate search before reporting it.
Description
The session-transfer flow does not reliably preserve client preferences. There are two independent problems in the current implementation:
prefs, but the transfer UI reads onlyprefsHttpand the receiver always writesprefsHttp.document.cookie. Passing that value to Expressres.cookie()encodes the percent signs again. On the destination,js-cookiedecodes once, leaving percent-encoded JSON thatJSON.parse()cannot parse.This is present on
developatf2cf95e06cd613fd0a06bbcb755e044c1dbfe306:welcome.tsreturns raw cookie wire text and reads onlyprefsHttppad_cookie.tsselectsprefson HTTPS and parses the decoded value as JSONres.cookie()underprefsHttpSteps to reproduce
The HTTPS source does not submit the
prefscookie. On HTTP, whereprefsHttpexists, a typical JSON cookie such as%7B%22...%22%7Dis submitted in encoded form and then encoded again when the destination cookie is written.Actual behavior
Preferences are missing or unreadable after transfer;
pad_cookie.tsfalls back after itsJSON.parse()failure.Expected behavior
The destination should receive the same preferences for both HTTP and HTTPS deployments, encoded exactly once in the cookie format expected by
js-cookie.Possible direction
Transfer a decoded/validated preference object or JSON string rather than cookie wire bytes, select the source/destination cookie name according to the request protocol, and let one layer perform cookie encoding.
No plugins are required. I found this while benchmarking an automated code-review workflow and manually verified the current source and duplicate search before reporting it.