Skip to content

Bear x-callback-url silently fails section replacement for headers containing / & [ ] | #72

@vasylenko

Description

@vasylenko

Summary

Bear's /add-text x-callback-url action with mode=replace and header parameter silently fails when the header text contains certain URL-significant characters: /, &, [, ], |. The URL is accepted, open -g exits 0, but Bear does not perform the replacement. No error is surfaced.

This is a Bear app bug in its x-callback-url handler — it appears to interpret these characters at the URL-parsing level before decoding percent-encoded parameter values.

Affected characters

Character Test Header Result
/ Topic r/bearapp ❌ Silent no-op
& Q&A Section ❌ Silent no-op
[ ] Release [v2.5] ❌ Silent no-op
| Option A | Option B ❌ Silent no-op

Characters confirmed working

= ? # % + : ; , @ ! ' " é — all 15 pass correctly.

Test methodology

Each character was tested with an isolated create → replace → verify → archive cycle using MCP Inspector CLI:

  1. Create a note with three ## sections, the middle one containing the special character in its header name
  2. Call bear-replace-text with scope=section targeting that header
  3. Wait 500ms for Bear to process
  4. Read the note back with bear-open-note and check whether the section content changed
  5. Archive the test note

All 4 failing characters exhibit the same behavior: bear-replace-text reports success, but bear-open-note shows the original section text unchanged.

Root cause hypothesis

Bear's x-callback-url handler parses these characters structurally before decoding percent-encoded values in the header parameter:

  • & is treated as a query parameter delimiter — header=Q&A Section becomes header=Q plus an orphan parameter A Section
  • / likely confuses internal URL path routing
  • [ ] have special meaning in RFC 3986 (IPv6 literals)
  • | is not valid in URIs; some parsers reject or mangle it

Impact

Section-level content replacement (/add-text?mode=replace&header=...) is unreliable for any note with these characters in section headers. Full-note-body replacement (mode=replace without header) is not affected.

Workaround

Perform section replacement client-side: read the full note, splice the section content in markdown, then use mode=replace without the header parameter to write the entire modified body.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions