Skip to content

Commit 7c5b9d6

Browse files
committed
🤖 fix: block svg skill files
- reject svg extensions/content types in isTextFile validation - add tests covering svg rejection in text file detection Tests: not run (bun not available)
1 parent b34a050 commit 7c5b9d6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

‎convex/lib/skills.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ describe('skills utils', () => {
150150
expect(isTextFile('note.txt', 'text/plain')).toBe(true)
151151
expect(isTextFile('data.any', 'application/json')).toBe(true)
152152
expect(isTextFile('data.json')).toBe(true)
153+
expect(isTextFile('icon.svg')).toBe(false)
154+
expect(isTextFile('icon.svg', 'image/svg+xml')).toBe(false)
153155
})
154156

155157
it('builds embedding text', () => {

‎convex/lib/skills.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ export function isTextFile(path: string, contentType?: string | null) {
125125
if (!trimmed) return false
126126
const parts = trimmed.split('.')
127127
const extension = parts.length > 1 ? (parts.at(-1) ?? '') : ''
128+
const normalizedContentType = contentType?.split(';', 1)[0]?.trim().toLowerCase() ?? ''
129+
if (normalizedContentType === 'image/svg+xml' || extension === 'svg') return false
128130
if (contentType) {
129131
if (isTextContentType(contentType)) return true
130132
}

0 commit comments

Comments
 (0)