Skip to content

Renaming a tag to a title with a double quote breaks every query that filters on it #1374

Open
logseq/logseq
#13871

Description

@yuxi-liu-wired

Steps

On a DB graph with a tag Project, blocks tagged #Project, and a query block {{query (tags [[Project]])}} made with /query (Tags filter, Project) on the page "Gremlin Home", on the web app:

  1. Open the tag page "Project".
  2. Click the page title, press End, type " and press Escape. The tag is now named Project".
  3. Open "Gremlin Home".

Expected

The query still lists the blocks tagged with the renamed tag. The query was never edited, and it stores the tag by reference.

Actual

The query block shows the error box "Query error: Report issue" with the text (tags [[Project"]]). The console shows {:renderer-query-failed {:kind :dsl, :error #error {:message "Unmatched delimiter ]." ...}}} from frontend.worker.handler.render-resource.query, and use-query-result rethrows it in render.

The steps reproduced it 3 of 3 times (Playwright, trusted input, a new graph each time).

Cause (read in code)

frontend.components.block/query-result takes the DSL string from the query block's title as the renderer receives it, where the tag appears by its current title ((tags [[Project"]])), and the worker parses that string again. logseq.db.frontend.query-dsl/pre-transform (deps/db/src/logseq/db/frontend/query_dsl.cljs) turns each page reference into an EDN string with

(string/replace s #"\"(?:\\.|[^\"\\])*\"|\[\[(.*?)\]\]" quoted-page-ref)

and quoted-page-ref puts the title between double quotes without escaping it. A " in the title ends that string early, a \ starts an escape, and a title containing ]] or [[ is cut at the first ]]. The reader then fails with "Unmatched delimiter", "Unsupported escape character" or "Invalid character". The app accepts all of these characters in a tag's title, so a rename breaks queries the user never touched.

Found by a monkey test (gremlins.js with trusted Playwright input): 22 of 401 runs ended in "Query error" boxes because the query did not parse (21 reader errors, 1 "Doesn't support name"). In all 22 the query text is the seeded (tags [[...]]) with the tag's title changed from Project, for example to Project[[Gremlin Garden]], [[Gremlin Home]], Project]] or \. In the 5 runs whose actions I read, the tag had been renamed on its page and the query block was not edited.

The steps above fail 3 of 3 times on the web build of master 16c4ed1a0.

Activity

  1. yuxi-liu-wired commented on Oct 6, 2026

    @yuxi-liu-wired
    Author

    Fix for " and \ in the title: logseq/logseq#13617. A title with ]] or [[ is not covered there.

  2. yuxi-liu-wired commented on Oct 6, 2026

    @yuxi-liu-wired
    Author

    logseq/logseq#13617 now also covers a title containing [[...]] / ]].

  3. yuxi-liu-wired commented on Oct 27, 2026

    @yuxi-liu-wired
    Author

    Fixed by logseq/logseq#13871, which replaces #13617 (closed). A tag title containing ", \ or a [[...]] pair no longer breaks a query that filters on the tag. tags-query-with-a-quote-or-backslash-in-the-tag-title renames four tags to Project", back\slash, say "#hi" and Project[[Gremlin Garden]] and finds each with (tags [[...]]). A title with an unbalanced ]], such as Project]], is not covered by that test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions