mail: all-ASCII draft bodies are hard-wrapped every 998 bytes, inserting newlines inside words and tags
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 80/100
Direzione di ricerca
Inizia in shortcuts/mail/emlbuilder/builder.go, presso selectCTE, lineWidthForCTE e writeFoldedBody, che l’issue indica come causa. Verifica come il builder gestisce i corpi text/html lunghi composti interamente da caratteri ASCII ed esegui i test esistenti pertinenti oppure aggiungi un caso di regressione per la riproduzione fornita. Il lavoro è completato quando l’HTML memorizzato mantiene intatti il testo originale e il markup se una riga supera i 998 byte.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
mail +draft-create, +reply, +reply-all, and +forward send the HTML part with Content-Transfer-Encoding: 7bit when the body is pure ASCII, and then split every line longer than 998 bytes by inserting a raw newline at byte 998, wherever that falls. A raw newline in a 7bit part is not a soft line break, so it is stored as part of the HTML:
- Text gets a stray space in the middle of a word (
word262comes back asword2+ newline +62, shown as "word2 62"). - When the cut lands inside a tag, markup is lost. The signature and the quoted original are appended on the same long line, so their markup is damaged even when the body itself is short (we see style attributes such as
font-familyandmargin-topdropped from signature lines).
A body that contains any non-ASCII byte is sent as base64 and is stored intact. +draft-edit does not seem to be affected.
Version
lark-cli 1.0.98 (Linux, installed from npm)
Steps to reproduce
BODY="<div>$(python3 -c "print(' '.join(f'word{i}' for i in range(300)))")</div>"
lark-cli mail +draft-create --to [email protected] --subject "fold test" --body "$BODY" --no-signature --as user
# Read the stored body back (use the draft_id printed above):
lark-cli mail user_mailbox.drafts get --as user \
--params '{"user_mailbox_id":"me","draft_id":"<draft_id>"}' \
| python3 -c "import json,sys,base64; h=json.load(sys.stdin)['data']['draft']['message']['body_html']; html=base64.urlsafe_b64decode(h+'='*(-len(h)%4)).decode(); print([i for i,c in enumerate(html) if c=='\n'])"
Observed: newlines at offsets 998 and 1997 of the stored body_html; the second one splits word262.
Expected: the body is stored exactly as given.
Running the same commands with one non-ASCII character anywhere in the body (for example é) stores it with no inserted newlines.
Cause
selectCTEreturns7bitfor any all-ASCII body.lineWidthForCTEreturns 998 for7bit, andwriteFoldedBodysplits each line at that width by inserting\n.
RFC 5322 does limit lines to 998 characters, but 7bit has no soft line break, so splitting a line changes the content.
Suggested fix
When a text part has a line longer than 998 bytes (or simply for every text/html part), encode it as quoted-printable, whose soft line breaks are removed on decoding, or as base64, as is already done for non-ASCII bodies, instead of folding a 7bit body.
Workaround
Any non-ASCII byte in the body makes the part base64, for example a non-rendering attribute on a wrapper element: <div data-x="✓">...</div>.
- Lingua principale
- Go
- Stelle
- 18.2k
- Fork
- 1.4k
- Merge medio
- 1g 3h
- PR unite (30g)
- 18
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di larksuite/cli
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
domain/im
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug domain/doc
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
auth: a 429 from the Token Endpoint during refresh deletes a still-valid loginForse già presa @linye157 l’ha presa 26 giorni fa. Apertabug domain/auth domain/im
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
larksuite/cli#2869 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
domain/core enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di larksuite/cli
Issue simili
-
test_archive_is_downloaded_after_logout_login doesn't wait for the storage client after loginAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
list_issues and search_issues: inconsistent `fields` allow-lists (`html_url` rejected by list)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
github/github-mcp-server#3960 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
JuliusBrussee/caveman#1594 ·
I maintainer di solito rispondono entro 1 giorno
-
C-bug O-community X-blathers-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
cockroachdb/cockroach#176264 · 1 commento ·
-
security trivy
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
kubefleet-dev/kubefleet#1068 ·
I maintainer di solito rispondono entro 3 giorni