fix(db): keep $ in page titles when replacing id refs by RaphaelFakhri · Pull Request #13816 · logseq/logseq · GitHub
Skip to content

fix(db): keep $ in page titles when replacing id refs - #13816

Open
RaphaelFakhri wants to merge 1 commit into
logseq:masterfrom
RaphaelFakhri:fix/literal-dollar-in-ref-titles
Open

RaphaelFakhri wants to merge 1 commit into
logseq:masterfrom
RaphaelFakhri:fix/literal-dollar-in-ref-titles

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

id-ref->title-ref and content-id-ref->page passed a page title to clojure.string/replace as the replacement string. JavaScript expands $$, $&, $` and $' in a replacement string, so a page titled cost$$ resolved to [[cost$]], and a$&b resolved to [[a[[<uuid>]]b]]. When a page is deleted, content-id-ref->page writes the changed title back to every block that referenced it.

This change adds a private replace-literal helper that matches the escaped string as a regex and inserts the title through a fn, so the title is inserted as is.

Tests

  • New id-ref->title-ref-test and content-id-ref->page-test in deps/db/test/logseq/db/frontend/content_test.cljs cover $$, $&, $` and $' in page refs and tags.
  • deps/db: 202 tests, 775 assertions, 0 failures.
  • deps/outliner: 158 tests, 808 assertions, 0 failures.
  • clj-kondo --lint src test in deps/db: 0 errors, 0 warnings.

Fixes logseq/db-test#1461

@CLAassistant

CLAassistant commented Oct 21, 2026 •

Copy link
Copy Markdown

Titles were passed as string/replace replacements, so $$, $&, $` and $' in a page title were expanded as JS replacement patterns.
@tiensonqin
tiensonqin force-pushed the fix/literal-dollar-in-ref-titles branch from 3467819 to a329b8f Compare October 21, 2026 13:26

This branch has not been deployed

No deployments
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.

Page titles with $$, $&, ` $ ` or $'` change when block refs are resolved

2 participants