Fix paste ownership, input bounds, and IPC validation

Supersedes #5745, #5746, and #5747.
This commit is contained in:
Jinwoo Hong
2026-06-19 17:14:55 -07:00
committed by GitHub
parent a5920b2183
commit 972078f2c4
592 changed files with 33301 additions and 3735 deletions
@@ -0,0 +1,45 @@
import { describe, expect, it } from 'vitest'
import {
GITHUB_PROJECT_REF_INPUT_MAX_BYTES,
getGitHubProjectRefInputByteLength,
hasBoundedGitHubProjectRefInputText,
isGitHubProjectRefInputTooLarge
} from './github-project-ref-input'
describe('GitHub project reference input limits', () => {
it('allows normal project references below the byte budget', () => {
expect(
isGitHubProjectRefInputTooLarge('https://github.com/orgs/acme/projects/42/views/3')
).toBe(false)
})
it('measures UTF-8 bytes instead of JavaScript string length', () => {
expect(getGitHubProjectRefInputByteLength('\u00e9')).toBe(2)
})
it('rejects oversized pasted project references', () => {
expect(isGitHubProjectRefInputTooLarge('x'.repeat(GITHUB_PROJECT_REF_INPUT_MAX_BYTES))).toBe(
false
)
expect(
isGitHubProjectRefInputTooLarge('x'.repeat(GITHUB_PROJECT_REF_INPUT_MAX_BYTES + 1))
).toBe(true)
})
it('rejects multibyte project references whose character count is below the limit', () => {
const reference = '😀'.repeat(Math.floor(GITHUB_PROJECT_REF_INPUT_MAX_BYTES / 4) + 1)
expect(reference.length).toBeLessThan(GITHUB_PROJECT_REF_INPUT_MAX_BYTES)
expect(isGitHubProjectRefInputTooLarge(reference)).toBe(true)
})
it('rejects oversized whitespace before submit checks trim the reference', () => {
const oversizedWhitespace = ' '.repeat(GITHUB_PROJECT_REF_INPUT_MAX_BYTES + 1)
expect(isGitHubProjectRefInputTooLarge(oversizedWhitespace)).toBe(true)
expect(hasBoundedGitHubProjectRefInputText(oversizedWhitespace)).toBe(false)
expect(hasBoundedGitHubProjectRefInputText(' acme/42 ')).toBe(true)
expect(hasBoundedGitHubProjectRefInputText(' ')).toBe(false)
})
})