Skip to content

Commit 815585d

Browse files
committed
fix(telemetry): skip string literals in raw slot detection
1 parent b3a9c29 commit 815585d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

workers/src/telemetry.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,23 @@ const RAW_SLOT_PATTERN = /\b(blob[1-9]|double[1-9])\b/gi;
458458
/**
459459
* Reject queries that contain raw slot names (blob1..9 / double1..6).
460460
* Returns an error message string, or null if the query is clean.
461+
*
462+
* Single-quoted string literals are skipped so that values like
463+
* `'https://example.com/blob1/readme'` do not trigger a false rejection.
464+
* This matches the scoping rules used by `rewriteSqlToRaw`. SQL's
465+
* doubled-quote escape (`''`) is respected so that escaped quotes do not
466+
* terminate the literal prematurely.
461467
* Exported for unit testing.
462468
*/
463469
export function detectRawSlotNames(
464470
sql: string,
465471
schemaMap: SchemaMap,
466472
): string | null {
467-
const matches = sql.match(RAW_SLOT_PATTERN);
473+
// Strip single-quoted string literals before scanning for raw slot names
474+
// so filter values containing substrings like `blob1` are not flagged.
475+
const literalPattern = /'(?:[^']|'')*'/g;
476+
const scannable = sql.replace(literalPattern, "''");
477+
const matches = scannable.match(RAW_SLOT_PATTERN);
468478
if (!matches) return null;
469479

470480
const unique = [...new Set(matches.map((m) => m.toLowerCase()))];

0 commit comments

Comments
 (0)