-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(zoom): iteratively strip tags in transcript parser to close incomplete-sanitization gap #4745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
waleedlatif1
merged 2 commits into
staging
from
waleedlatif1/zoom-transcript-sanitization
May 26, 2026
+97
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { parseVtt } from '@/connectors/zoom/zoom' | ||
|
|
||
| const HEADER = 'WEBVTT\n\n' | ||
|
|
||
| describe('parseVtt', () => { | ||
| it.concurrent('returns empty string for input with no cues', () => { | ||
| expect(parseVtt(HEADER)).toBe('') | ||
| }) | ||
|
|
||
| it.concurrent('extracts plain spoken text from a single cue', () => { | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\nHello world\n` | ||
| expect(parseVtt(vtt)).toBe('Hello world') | ||
| }) | ||
|
|
||
| it.concurrent('preserves WebVTT voice tags as "Speaker: text"', () => { | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\n<v Alice>hello there</v>\n` | ||
| expect(parseVtt(vtt)).toBe('Alice: hello there') | ||
| }) | ||
|
|
||
| it.concurrent('preserves voice tags with class suffix', () => { | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\n<v.host Bob>welcome</v>\n` | ||
| expect(parseVtt(vtt)).toBe('Bob: welcome') | ||
| }) | ||
|
|
||
| it.concurrent('strips inline formatting tags but keeps text', () => { | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\n<b>bold</b> and <i>italic</i>\n` | ||
| expect(parseVtt(vtt)).toBe('bold and italic') | ||
| }) | ||
|
|
||
| it.concurrent('strips karaoke timestamp tags', () => { | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\nhello <00:00:01.000>world\n` | ||
| expect(parseVtt(vtt)).toBe('hello world') | ||
| }) | ||
|
|
||
| it.concurrent('strips class spans', () => { | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\n<c.loud>SHOUT</c>\n` | ||
| expect(parseVtt(vtt)).toBe('SHOUT') | ||
| }) | ||
|
|
||
| it.concurrent('skips cue identifier lines before timing', () => { | ||
| const vtt = `${HEADER}cue-1\n00:00:00.000 --> 00:00:02.000\nhello\n` | ||
| expect(parseVtt(vtt)).toBe('hello') | ||
| }) | ||
|
|
||
| it.concurrent('joins multiple cues with newlines', () => { | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\nfirst\n\n00:00:02.000 --> 00:00:04.000\nsecond\n` | ||
| expect(parseVtt(vtt)).toBe('first\nsecond') | ||
| }) | ||
|
|
||
| it.concurrent('collapses repeated whitespace within a cue', () => { | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\nhello world\n` | ||
| expect(parseVtt(vtt)).toBe('hello world') | ||
| }) | ||
|
|
||
| it.concurrent('iteratively strips overlapping tags that reconstruct after one pass', () => { | ||
| const crafted = '<<b>b>injected</<b>b>' | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\n${crafted}\n` | ||
| const result = parseVtt(vtt) | ||
| expect(result).not.toMatch(/<\/?[^>]+>/) | ||
| expect(result).toContain('injected') | ||
| }) | ||
|
|
||
| it.concurrent('iteratively strips nested script-like tag fragments', () => { | ||
| const crafted = '<scr<script>ipt>alert(1)</scr</script>ipt>' | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\n${crafted}\n` | ||
| const result = parseVtt(vtt) | ||
| expect(result).not.toMatch(/<\/?[^>]+>/) | ||
| expect(result.toLowerCase()).not.toContain('script') | ||
| }) | ||
|
|
||
| it.concurrent('sanitizes crafted speaker names that embed tag fragments', () => { | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\n<v <b>Evil</b>>payload</v>\n` | ||
| const result = parseVtt(vtt) | ||
| expect(result).not.toMatch(/<\/?[^>]+>/) | ||
| }) | ||
|
|
||
| it.concurrent('terminates on adversarial deeply-nested input', () => { | ||
| const crafted = `${'<'.repeat(50)}b${'>'.repeat(50)}text${'<'.repeat(50)}/b${'>'.repeat(50)}` | ||
| const vtt = `${HEADER}00:00:00.000 --> 00:00:02.000\n${crafted}\n` | ||
| const result = parseVtt(vtt) | ||
| expect(result).not.toMatch(/<\/?[^>]+>/) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.