From 31476041694bb4c70935d819977ac306e2ffc4d6 Mon Sep 17 00:00:00 2001 From: Morten Harders Date: Fri, 6 Nov 2026 11:08:16 +0100 Subject: [PATCH] fix(grid): escape backslashes when copying rows as Markdown A cell containing '\|' was copied as '\\|', which Markdown reads as a backslash followed by a column break. Escape backslashes as well as pipes (CodeQL js/incomplete-sanitization). Also note why sslmode=require skips certificate checks. --- frontend/src/util.ts | 2 +- internal/db/db.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/util.ts b/frontend/src/util.ts index 1dffd68..2e57eab 100644 --- a/frontend/src/util.ts +++ b/frontend/src/util.ts @@ -121,7 +121,7 @@ export function rowsAs(format: 'csv' | 'tsv' | 'json' | 'sql' | 'markdown' | 'ph return rows.length === 1 ? one(rows[0]) + ';' : '[\n' + rows.map((r) => one(r).replace(/^/gm, ' ')).join(',\n') + ',\n];'; } case 'markdown': { - const esc = (v: unknown) => cellText(v).replace(/\|/g, '\\|').replace(/\n/g, ' '); + const esc = (v: unknown) => cellText(v).replace(/[\\|]/g, '\\$&').replace(/\n/g, ' '); return [`| ${columns.map(esc).join(' | ')} |`, `| ${columns.map(() => '---').join(' | ')} |`, ...rows.map((r) => `| ${r.map(esc).join(' | ')} |`)].join('\n'); } } diff --git a/internal/db/db.go b/internal/db/db.go index 27d0a79..55db2aa 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -167,7 +167,7 @@ func (c *Conn) openMySQL(database string) (*sql.DB, error) { mc.Timeout = 10 * time.Second switch c.Cfg.SSLMode { case "", "disable": - case "require": + case "require": // like libpq: encrypt, but verify nothing; verify-ca and verify-full check the certificate mc.TLS = &tls.Config{InsecureSkipVerify: true} default: tc, err := c.tlsConfig()