Fix paste ownership, input bounds, and IPC validation
Supersedes #5745, #5746, and #5747.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import {
|
||||
GITHUB_WORK_ITEMS_QUERY_MAX_BYTES,
|
||||
isGitHubWorkItemsQueryTooLarge
|
||||
} from './github-work-items-query-bounds'
|
||||
|
||||
describe('shared GitHub work item query bounds', () => {
|
||||
it('allows normal GitHub search syntax', () => {
|
||||
expect(isGitHubWorkItemsQueryTooLarge('is:issue is:open label:bug')).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects oversized pasted work item queries by byte length', () => {
|
||||
expect(isGitHubWorkItemsQueryTooLarge('x'.repeat(GITHUB_WORK_ITEMS_QUERY_MAX_BYTES))).toBe(
|
||||
false
|
||||
)
|
||||
expect(isGitHubWorkItemsQueryTooLarge('x'.repeat(GITHUB_WORK_ITEMS_QUERY_MAX_BYTES + 1))).toBe(
|
||||
true
|
||||
)
|
||||
})
|
||||
|
||||
it('rejects multibyte pasted queries whose character count is below the limit', () => {
|
||||
const query = '😀'.repeat(Math.floor(GITHUB_WORK_ITEMS_QUERY_MAX_BYTES / 4) + 1)
|
||||
|
||||
expect(query.length).toBeLessThan(GITHUB_WORK_ITEMS_QUERY_MAX_BYTES)
|
||||
expect(isGitHubWorkItemsQueryTooLarge(query)).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user