readest/apps
Huang Xin 866944d2bb
fix(sync): drop NUL from reading-stats book titles before saving (#8095) (#8097)
The KOReader plugin's "Push reading stats" failed every time with "The
server is temporarily unavailable". The reporter's KOReader log has the
server's answer: HTTP 500 "unsupported Unicode escape sequence".

PostgreSQL can't store U+0000 in text, so one "\u0000" in a JSON string
fails the whole statement. KOReader's statistics database can hold a book
title or author with a NUL byte, and the plugin's dkjson encoder sends it
as \u0000. The stat_books upsert then returns 500. The push cursor only
advances on success, so every later push resent the same chunk and failed.

Books and notes already strip NUL with sanitizeString in transform.ts.
The stat_books upsert added later never did. Run its title and authors
through the same helper. Since the fix is server-side, older plugins work
once web is deployed.

Verified:
- New test sync-strip-nul.test.ts (its mock rejects \u0000 like
  PostgREST). Without the fix: "expected 500 to be 200". With it: passes.
- PostgreSQL 15: json_populate_recordset with "A\u0000B" gives "unsupported
  Unicode escape sequence"; the same row with "AB" inserts.
- pnpm test: all files pass. pnpm lint: clean.
- Not run: a real push from KOReader against a server with this fix. The
  reporter's device is a Kobo, and which book holds the NUL is unknown.

Reported on Reddit, with the KOReader log sent by email.

Co-authored-by: Claude Code (Claude Opus 5.5) <noreply@anthropic.com>
2026-11-29 04:07:46 +01:00
..
readest-app fix(sync): drop NUL from reading-stats book titles before saving (#8095) (#8097) 2026-11-29 04:07:46 +01:00
readest-calibre-plugin feat(calibre): add multi-language support (#6768) 2026-10-13 18:46:06 +02:00
readest-crosspoint-plugin feat(crosspoint): sign in with a code through /api/auth/device (owner: "use a more generic path for /api/crosspoint/device/code") (#7859) 2026-11-24 04:21:00 +01:00
readest.koplugin feat(kosync): match file names across readers with a format or a book's own name (#7864) (#7873) 2026-11-24 08:32:36 +01:00