Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
A very long note opens, and one with no text says so
Yashwanth Kamireddi6c5b732405ae
diff --git a/.uiverify/notes-no-text.mjs b/.uiverify/notes-no-text.mjsnew file mode 100644index 0000000..6452b4f--- /dev/null+++ b/.uiverify/notes-no-text.mjs@@ -0,0 +1,29 @@+// A note the library holds no text for (not yet arrived, or one Skykeep can't read): said in+// words, never an "Opening…" that never ends; a note with its text opens as ever.+import { engine } from "./engine.mjs";+import { SERVICES, installStub } from "./stub.mjs";+const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: 1280, height: 820 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null,+ calendarFixture: false, notesFixture: true, contactsFixture: false, driveFixture: false, remindersFixture: false });+await ctx.addInitScript(() => { window.__noText = "n1"; });+const page = await ctx.newPage();+page.on("pageerror", (e) => { console.log(`FAIL page error: ${e.message}`); process.exitCode = 1; });+await page.goto(process.env.BASE ?? process.env.URL ?? "http://localhost:4173", { waitUntil: "networkidle" });+await page.locator(".nav-item", { hasText: "Notes" }).click();+await page.waitForTimeout(400);+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+await page.locator(".note-row", { hasText: "Curtains" }).click();+await page.waitForTimeout(900);+const said = await page.locator(".note-loading").innerText().catch(() => "");+ok(/isn't here yet/.test(said) && /safe in iCloud/.test(said), `a note with no text says so ${JSON.stringify(said.slice(0, 60))}`);+ok((await page.locator(".note-loading", { hasText: "Opening" }).count()) === 0, "and never shows Opening…");+ok((await page.locator("[contenteditable='true'].note-text, textarea.note-text").count()) === 0, "nothing to type into, so nothing empty is written back");+const other = page.locator(".note-row").filter({ hasNotText: "Curtains" }).first();+await other.click();+await page.waitForTimeout(600);+ok((await page.locator(".note-loading").count()) === 0, "a note with its text opens as ever");+await b.close();+console.log(failures ? `${failures} FAILED` : "all passed");+process.exit(failures ? 1 : 0);diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex cd75346..2006e63 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -922,7 +922,8 @@ export function installStub({ screen, services, twoFactor, calendarFixture, notewindow.__table[args.row][args.column] = args.text;return window.__table.map((r) => r.slice());}- case "note_body": return (noteList.find((n) => n.guid === args?.guid) ?? {}).body ?? null;+ // `__noText`: a note the library holds no text for (not yet arrived, or unreadable).+ case "note_body": return args?.guid === window.__noText ? null : (noteList.find((n) => n.guid === args?.guid) ?? {}).body ?? null;case "note_row": {const n = noteList.find((x) => x.guid === args?.guid);return n ? { ...n, body: null } : null;diff --git a/check.sh b/check.shindex 6f48220..8d11423 100755--- a/check.sh+++ b/check.sh@@ -96,6 +96,7 @@ step "photo search" node .uiverify/photos-search.mjsstep "full quality" node .uiverify/photos-quality.mjsstep "library switcher" node .uiverify/photos-library-switcher.mjsstep "notes delete" node .uiverify/notes-delete.mjs+step "notes no text" node .uiverify/notes-no-text.mjsstep "empty today" node .uiverify/reminders-empty.mjsstep "calendar keys" node .uiverify/calendar-keys.mjsstep "reminders instant" node .uiverify/reminders-instant.mjsdiff --git a/crates/quince-icloud/src/ckdocument.rs b/crates/quince-icloud/src/ckdocument.rsindex faecbb6..763bbc3 100644--- a/crates/quince-icloud/src/ckdocument.rs+++ b/crates/quince-icloud/src/ckdocument.rs@@ -15,9 +15,11 @@ use base64::{engine::general_purpose::STANDARD as B64, Engine};/// Where the readable text lives inside the document protobuf.const TEXT_PATH: &[u64] = &[2, 3, 2];-/// A payload larger than this is not a reminder title or a note body; refuse it rather than-/// decompress something hostile.-const MAX_DECOMPRESSED: u64 = 8 * 1024 * 1024;+/// The most a document may unpack to. It bounds a hostile payload (a few kilobytes that would+/// inflate to gigabytes), and is far above any real note: 8 MB, the limit once guessed here,+/// is a long journal or a pasted book, and such a note opened as nothing at all. A note's text+/// is several bytes a character with its formatting, so this is tens of millions of characters.+const MAX_DECOMPRESSED: u64 = 128 * 1024 * 1024;/// Wire types we can advance past. Anything else means the bytes are not what we expect.const WIRE_VARINT: u64 = 0;@@ -2380,6 +2382,23 @@ fn looks_like_message(bytes: &[u8]) -> bool {#[cfg(test)]mod tests {++ /// A very long note, far past the 8 MB once refused, reads whole; a payload that would+ /// unpack past the ceiling is still refused, not decompressed.+ #[test]+ fn a_very_long_note_reads_and_a_bomb_does_not() {+ use std::io::Write as _;+ let long = "All work and no play. ".repeat(600_000); // ~13 MB of text+ let encoded = text_to_base64(&long);+ assert_eq!(text_from_base64(&encoded).as_deref(), Some(long.as_str()));+ let mut gz = flate2::write::GzEncoder::new(Vec::new(), flate2::Compression::best());+ gz.write_all(&vec![0u8; 200 * 1024 * 1024]).unwrap();+ let bomb = gz.finish().unwrap();+ assert!(+ inflate(&bomb).is_none(),+ "a payload past the ceiling was unpacked"+ );+ }use super::*;use std::io::Write;diff --git a/src/screens/NotesView.tsx b/src/screens/NotesView.tsxindex d749995..314b1e3 100644--- a/src/screens/NotesView.tsx+++ b/src/screens/NotesView.tsx@@ -569,6 +569,10 @@ export function NotesView() {.then(([text, runs]) => {if (cancelled) return;setLoadedRuns((cur) => (runs !== null ? { guid: openGuid, runs } : cur?.guid === openGuid ? cur : { guid: openGuid, runs: [] }));+ // The library holds no text for it: not yet arrived, or a note Skykeep can't read.+ // Said as such, never an "Opening…" that never ends; the next read after a sync+ // replaces it the moment the text is there.+ setNoText(text === null ? openGuid : null);if (text === null) return;// Never over what is being typed. A refresh follows every save, and adopting its// answer under someone's cursor is how a half-saved note replaced a whole one. Typing@@ -1361,6 +1365,8 @@ export function NotesView() {// the spinner it used to show first was a flash on every note opened.const waiting = Boolean(open && !open.locked && (body === null || (open.editable && runs === null)));const [slow, setSlow] = useState(false);+ /** The note whose read just came back with no text in the library. */+ const [noText, setNoText] = useState<string | null>(null);useEffect(() => {setSlow(false);if (!waiting) return undefined;@@ -1867,7 +1873,14 @@ export function NotesView() {/* Nothing to type into until the note's own text has arrived: an empty box over anote whose body had not loaded would write that emptiness back. Said only once itis slow in coming. */- slow && <EmptyState busy className="note-loading">Opening…</EmptyState>+ open && noText === open.guid ? (+ <EmptyState className="note-loading">+ This note's text isn't here yet. If it doesn't appear after the next sync, Skykeep+ can't read it, but it's safe in iCloud: open it on your iPhone, iPad or Mac.+ </EmptyState>+ ) : (+ slow && <EmptyState busy className="note-loading">Opening…</EmptyState>+ )) : open ? (<div className="note-editor is-readonly"><h1 className="note-title">{splitTitle(body ?? "").title}</h1>