8000 fix: allow `count(*)` query · nuxt/content@71221d3 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 71221d3

Browse files
farnabazziadsarour
andcommitted
fix: allow count(*) query
resolves #3136 Co-Authored-By: Ziad <8212468+ziadsarour@users.noreply.github.com>
1 parent cc2e902 commit 71221d3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/runtime/internal/security.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const SQL_COMMANDS = /SELECT|INSERT|UPDATE|DELETE|DROP|ALTER|\$/i
2-
const SQL_COUNT_REGEX = /COUNT\((DISTINCT )?[a-z_]\w+\)/i
2+
const SQL_COUNT_REGEX = /COUNT\((DISTINCT )?([a-z_]\w+|\*)\)/i
33
const SQL_SELECT_REGEX = /^SELECT (.*) FROM (\w+)( WHERE .*)? ORDER BY (["\w,\s]+) (ASC|DESC)( LIMIT \d+)?( OFFSET \d+)?$/
44

55
/**

test/unit/assertSafeQuery.test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ describe('decompressSQLDump', () => {
6060
await collectionQueryBuilder(mockCollection, mockFetch).all()
6161
expect(() => assertSafeQuery(mockFetch.mock.lastCall![1], mockCollection)).not.toThrow()
6262

63+
await collectionQueryBuilder(mockCollection, mockFetch).count()
64+
expect(() => assertSafeQuery(mockFetch.mock.lastCall![1], mockCollection)).not.toThrow()
65+
6366
await collectionQueryBuilder(mockCollection, mockFetch).count('stem')
6467
expect(() => assertSafeQuery(mockFetch.mock.lastCall![1], mockCollection)).not.toThrow()
6568

0 commit comments

Comments
 (0)
0