Skip to content

Commit 4d59543

Browse files
author
Erik Hofer
committed
Fix missing SQL output if SQL is invalid
1 parent 1a7e46b commit 4d59543

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/InjectionVisualizer/lexer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
// source: https://www.regextester.com/?fam=110716
3-
const REGEX = /(\b(?:select|from|where|group|by|order|or|and|not|exists|having|join|left|right|inner)\b)|([A-Za-z][A-Za-z0-9]*)|([0-9]+\.[0-9]*)|([0-9]+)|('[^']*')|(\s+)|(\-\-[^\n\r]*)|([+\-\*/.=\(\),;])/gmi;
3+
const REGEX = /(\b(?:select|from|where|group|by|order|or|and|not|exists|having|join|left|right|inner)\b)|([A-Za-z][A-Za-z0-9]*)|([0-9]+\.[0-9]*)|([0-9]+)|('[^']*')|(\s+)|(\-\-[^\n\r]*)|([+\-\*/.=\(\),;])|(.)/gmi;
44

55
export type Token = {
6-
type: 'keyword' | 'identifier' | 'operator' | 'string' | 'integer' | 'decimal' | 'comment' | 'whitespace'
6+
type: 'keyword' | 'identifier' | 'operator' | 'string' | 'integer' | 'decimal' | 'comment' | 'whitespace' | 'unknown'
77
text: string
88
}
99

@@ -16,7 +16,8 @@ const TOKEN_TYPES_BY_GROUP_INDEX: Array<Token['type'] | undefined> = [
1616
'string',
1717
'whitespace',
1818
'comment',
19-
'operator'
19+
'operator',
20+
'unknown'
2021
]
2122

2223
export function tokenize(sql: string) {

0 commit comments

Comments
 (0)