MCPcopy Create free account
hub / github.com/bytebase/dbhub / scanMultiLineCommentMySQL

Function scanMultiLineCommentMySQL

src/utils/sql-parser.ts:59–65  ·  view source on GitHub ↗

* MySQL/MariaDB-specific multi-line comment scanner that preserves conditional comments. * MySQL conditional comments (`/*!nnnnn ... *\/`) and MariaDB-specific comments * (`/*M! ... *\/`) are executable. Stripping them would let malicious SQL bypass * read-only checks, so we return null to let th

(sql: string, i: number)

Source from the content-addressed store, hash-verified

57 * read-only checks, so we return null to let them pass through as plain text.
58 */
59function scanMultiLineCommentMySQL(sql: string, i: number): SQLToken | null {
60 if (sql[i] !== "/" || sql[i + 1] !== "*") { return null; }
61 const next = sql[i + 2];
62 const nextNext = sql[i + 3];
63 if (next === "!" || (next === "M" && nextNext === "!")) { return null; }
64 return scanMultiLineComment(sql, i);
65}
66
67function scanNestedMultiLineComment(sql: string, i: number): SQLToken | null {
68 if (sql[i] !== "/" || sql[i + 1] !== "*") { return null; }

Callers 1

scanTokenMySQLFunction · 0.85

Calls 1

scanMultiLineCommentFunction · 0.85

Tested by

no test coverage detected