Skip to content

Add an OS clipboard watcher for hidden Unicode - #116

Merged
cursor[bot] merged 2 commits into
mainfrom
cursor/clipboard-watcher-cdf8
Sep 2, 2026
Merged

Add an OS clipboard watcher for hidden Unicode#116
cursor[bot] merged 2 commits into
mainfrom
cursor/clipboard-watcher-cdf8

Conversation

@byte271

@byte271 byte271 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

OS clipboard watcher for the shared fuckmark-hidden-scan-v1 engine (Pillar B item 7).

Stack: merge #112#113#114#115 → this. Base is cursor/scan-language-bindings-cdf8 (includes Codex P2 follow-up b76f013).

What landed

  • CLI: fuckmark clipboard scan / clean / watch
  • Reads via pbpaste, wl-paste, xclip -o, xsel, or PowerShell Get-Clipboard -Raw
  • Writes through the existing CLI copy helpers
  • Default categories match fuckmark lint (Trojan Source bidi, zero-width, tag smuggling, controls, noncharacters, surrogates)
  • --clean rewrites the clipboard in place
  • Keeps real emoji ZWJ sequences (both neighbors emoji) and info-level variation selectors, matching browser paste-safe
  • --json, -q, --select, --once, --exit-on-find, --interval, --max-seconds
  • Exit 0 clean, 1 findings (including after a successful clean), 2 usage, 3 clipboard unavailable
  • Python: evaluate_clipboard_text, watch_clipboard, clean_clipboard_text with injectable reader/writer/clock for tests
  • Docs: docs/clipboard.md, plus CLI / README / CHANGELOG / install notes
  • Tests never touch a real clipboard

Codex P2 follow-up (5cfa925)

  • Snapshots hash with UTF-8 surrogatepass so a lone surrogate does not crash watch
  • Linux read uses wl-paste without --no-newline, so a real trailing newline is kept
  • watch --clean re-reads and compares digests before writing, so a newer copy is not overwritten

Algorithm id: fuckmark-clipboard-watch-v1. Package version stays 0.4.1. Frozen confirmation artifacts are unchanged.

Open in Web Open in Cursor 

@byte271
byte271 marked this pull request as ready for review September 2, 2026 02:59
@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 48a2724c-a783-4aa3-98d8-e2bd72a07493

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Introduce `fuckmark clipboard scan|clean|watch` so copied text is checked
for Trojan Source, zero-width, and tag smuggling. Emoji ZWJ sequences
stay intact. Tests inject a fake clipboard.

Co-authored-by: Byte271 <byte271@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/clipboard-watcher-cdf8 branch from c336e2b to cf17ba6 Compare September 2, 2026 03:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c336e2bf0b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread fuckmark/clipboard_watch.py Outdated


def _digest(text: str) -> str:
return hashlib.sha256(text.encode("utf-8")).hexdigest()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hash surrogate-containing snapshots without strict UTF-8

When an injected reader or OS backend returns a string containing a lone surrogate—the default category set explicitly includes surrogate—this strict UTF-8 encoding raises UnicodeEncodeError before the scanner runs. Consequently, watch_clipboard() crashes instead of detecting or cleaning precisely this supported input; hash the Python string with a surrogate-preserving encoding or an encoding-independent representation.

Useful? React with 👍 / 👎.

Comment thread fuckmark/clipboard_watch.py Outdated
("powershell.exe", "-NoProfile", "-Command", "Get-Clipboard -Raw"),
)
return (
("wl-paste", "--no-newline"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve trailing newlines when reading with wl-paste

On Wayland, the first successful command always uses wl-paste --no-newline, so a legitimate final newline is removed from the clipboard text. A scan therefore examines content different from what was copied, and if any hidden character triggers clean, the rewritten clipboard permanently loses that newline; use the unmodified wl-paste output as the primary read.

Useful? React with 👍 / 👎.

if on_alert is not None:
on_alert(alert, snap)
if clean and alert.removed:
write(alert.cleaned)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recheck the clipboard before overwriting it

With watch --clean, if the user copies new content after read() but before this write—there is an explicit synchronous on_alert callback in that window—the cleaner overwrites the newer clipboard with a cleaned version of the stale snapshot. Re-read and verify the digest immediately before writing so rapid copy operations cannot lose unrelated clipboard data.

Useful? React with 👍 / 👎.

Hash snapshots with UTF-8 surrogatepass, read Wayland paste without
stripping a trailing newline, and re-check the clipboard digest
before --clean overwrites a newer copy.

Co-authored-by: Byte271 <byte271@users.noreply.github.com>
@cursor
cursor Bot changed the base branch from cursor/scan-language-bindings-cdf8 to main September 2, 2026 03:12
@cursor
cursor Bot merged commit 8f56bcf into main Sep 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants