-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix(gmail): RFC 2047 encode subject headers for non-ASCII characters #3526
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
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bc6c86b
fix(gmail): RFC 2047 encode subject headers for non-ASCII characters
waleedlatif1 f207f8e
Fix RFC 2047 encoded word length limit
cursoragent b05f0b3
fix(gmail): split RFC 2047 encoded words on character boundaries
waleedlatif1 12fd2eb
fix(gmail): simplify RFC 2047 encoding to match Google's own sample
waleedlatif1 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
Fix RFC 2047 encoded word length limit
Split long email subjects into multiple RFC 2047 encoded words to comply with the 75-character limit per RFC 2047 Section 2. Each encoded word now contains at most 45 bytes of UTF-8 content (producing max 60 chars of base64 + 12 chars overhead = 72 total). Multiple encoded words are separated by CRLF + space (folding whitespace). Applied via @cursor push command
- Loading branch information
commit f207f8e3ca9c57c290a903b926febf7e61ea3f25
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,47 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { encodeRfc2047 } from './utils' | ||
|
|
||
| describe('encodeRfc2047', () => { | ||
| it('returns ASCII text unchanged', () => { | ||
| const input = 'Simple ASCII Subject' | ||
| expect(encodeRfc2047(input)).toBe(input) | ||
| }) | ||
|
|
||
| it('encodes short non-ASCII text in a single encoded word', () => { | ||
| const input = 'Hello 世界' | ||
| const result = encodeRfc2047(input) | ||
| expect(result).toMatch(/^=\?UTF-8\?B\?[A-Za-z0-9+/=]+\?=$/) | ||
| expect(result.length).toBeLessThanOrEqual(75) | ||
| }) | ||
|
|
||
| it('splits long non-ASCII text into multiple encoded words', () => { | ||
| const input = '今週のミーティングアジェンダについて検討します' | ||
| const result = encodeRfc2047(input) | ||
| expect(result).toContain('\r\n ') | ||
| const words = result.split('\r\n ') | ||
| expect(words.length).toBeGreaterThan(1) | ||
| words.forEach((word) => { | ||
| expect(word.length).toBeLessThanOrEqual(75) | ||
| expect(word).toMatch(/^=\?UTF-8\?B\?[A-Za-z0-9+/=]+\?=$/) | ||
| }) | ||
| }) | ||
|
|
||
| it('handles very long subjects with emojis', () => { | ||
| const input = '🎉 '.repeat(30) | ||
| const result = encodeRfc2047(input) | ||
| const words = result.split('\r\n ') | ||
| words.forEach((word) => { | ||
| expect(word.length).toBeLessThanOrEqual(75) | ||
| expect(word).toMatch(/^=\?UTF-8\?B\?[A-Za-z0-9+/=]+\?=$/) | ||
| }) | ||
| }) | ||
|
|
||
| it('handles edge case of exactly 47 bytes of UTF-8', () => { | ||
| const input = 'a'.repeat(47) | ||
| const result = encodeRfc2047(input) | ||
| expect(result).not.toContain('\r\n ') | ||
| }) | ||
| }) |
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.