janeczku / calibre-web

:books: Web app for browsing, reading and downloading eBooks stored in a Calibre database
GNU General Public License v3.0
11.99k stars 1.28k forks source link

fix: change bytes-encoded token to unicode string #3042

Closed potatoeggy closed 1 month ago

potatoeggy commented 2 months ago

b64encode returns a bytes object, meaning that SyncToken.build_sync_token returns something like b'eyrestOfToken'. When we later set it as a header, Flask (or something else internally) calls str on whatever was passed. A str'd bytes object wraps it in quotes in its repr'd form, so we get "b'eyrestOfToken" which is not base64-decodable.

This fixes an issue where sync tokens can never be read and endlessly loop, causing every sync to fail.