From 1fe8c73d01390eebc71c8b94f8c3c316462ec66b Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Tue, 18 Aug 2026 20:11:51 -0400 Subject: [PATCH] Fix pull sync rejecting every annotation: off-by-one in pos0 validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit isValidPos0 compared pos0:sub(1,7) against the 6-char string '/body/', so it tested '/body/D' == '/body/' — false for every CRE xpointer, and applyServerAnnotations silently dropped ALL pulled highlights/notes/ bookmarks on rolling documents. Caught by running the real plugin code against the live server in a stubbed KOReader harness: push stored rows on the server, pull applied nothing — matching the reported 'neither direction syncs' symptom. sub(1,6) now matches. Both directions re-verified end-to-end through the actual plugin: a KOReader-style highlight pushes and lands in the server DB (with server-derived percentage), and a metadata pull populates a fresh device's bookmark list with web- and device-sourced highlights (xpointer pos0s) plus web bookmarks (numeric page pos0s on paging documents). --- main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.lua b/main.lua index 2faac39..a7839f5 100644 --- a/main.lua +++ b/main.lua @@ -1174,7 +1174,7 @@ function Bookhoard:applyServerAnnotations(annotations) if has_pages then return tonumber(pos0) ~= nil end - return pos0:sub(1, 7) == "/body/" + return pos0:sub(1, 6) == "/body/" end local function addOrUpdate(server_entry, has_text)