You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1] [bug] escapeIdentifier misleading name — splits into quoteStringLiteral + quoteIdentifier #444
[P1] [bug] escapeIdentifier is a misleading name — it single-quote-escapes (correct for usernames in CREATE/ALTER USER) but is reused in parseGrantStatements/categorizeGrants for user@host parsing, mixing scopes
Context
escapeIdentifier (userPrivileges.ts:62-64) does MySQL string-literal escaping ('value' with '' doubling), correct for user/host/password in CREATE USER / ALTER USER / SHOW GRANTS FOR.
Problem
Per docs/audits/admin.md F16.
Helper name suggests it quotes SQL identifiers (which would be backticks). Re-using for SHOW GRANTS FOR ${escapeIdentifier(user)}@${escapeIdentifier(host)} is correct because SHOW GRANTS FOR expects single-quoted user/host literals — but the look is confusing. PrivilegesEditor builds dbScope = \${selectedDb}`.*(line 760) with raw backticks (no helper) — inconsistency. New contributors reach forescapeIdentifierand write`${escapeIdentifier(dbTable)}`because the name promises identifier escaping — produces invalid SQL like``db.table```.
Scope S. Rename escapeIdentifier → quoteStringLiteral (or split into quoteUser, quoteHost, quotePassword); add separate quoteIdentifier that backtick-escapes and doubles backticks. Update 7 call sites.
Acceptance
Identifier escaping helpers are unambiguous; weird-name tables don't break GRANT/REVOKE.
Done in #521. The two same-named functions are now one module, src/lib/sql-quote.ts, split into quoteIdentifier (backticks, for names) and quoteStringLiteral (quotes, for values).
The split turned up a bug the naming was hiding. The admin helper doubled single quotes but left backslashes alone, and MySQL treats a backslash as an escape inside a string literal unless NO_BACKSLASH_ESCAPES is set — off by default. A password of pa\\ss was stored as pass; the statement succeeded and the account got a password the user never typed. Verified by authenticating: the typed password was rejected and the collapsed one accepted. An integration test now pins the round trip.
Also fixed the one admin call site that needed an identifier and had no helper for it, so it hand-rolled backticks without doubling — a database named we\ird` made the GRANT fail to parse.
Reopen if you would rather the remaining escapeIdentifier name in backup-generator.ts also change; it is now just a re-export of quoteIdentifier.
Activity
fix(admin): quote passwords as string literals, and names as identifi…
EVWorth commentedon Aug 29, 2026
Done in #521. The two same-named functions are now one module,
src/lib/sql-quote.ts, split intoquoteIdentifier(backticks, for names) andquoteStringLiteral(quotes, for values).The split turned up a bug the naming was hiding. The admin helper doubled single quotes but left backslashes alone, and MySQL treats a backslash as an escape inside a string literal unless NO_BACKSLASH_ESCAPES is set — off by default. A password of
pa\\sswas stored aspass; the statement succeeded and the account got a password the user never typed. Verified by authenticating: the typed password was rejected and the collapsed one accepted. An integration test now pins the round trip.Also fixed the one admin call site that needed an identifier and had no helper for it, so it hand-rolled backticks without doubling — a database named
we\ird` made the GRANT fail to parse.Reopen if you would rather the remaining
escapeIdentifiername in backup-generator.ts also change; it is now just a re-export ofquoteIdentifier.fix(import): one escape table, and say what a dump will drop (#579)