mail: all-ASCII draft bodies are hard-wrapped every 998 bytes, inserting newlines inside words and tags
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 80/100
Línea de trabajo
Empieza en shortcuts/mail/emlbuilder/builder.go, en selectCTE, lineWidthForCTE y writeFoldedBody, que el issue identifica como la causa. Comprueba cómo gestiona el builder los cuerpos text/html largos compuestos totalmente por ASCII y ejecuta las pruebas existentes pertinentes o añade un caso de regresión para la reproducción proporcionada. El trabajo estará terminado cuando el HTML almacenado conserve intactos el texto original y el marcado si una línea supera los 998 bytes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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>.
- Lenguaje dominante
- Go
- Estrellas
- 18.2k
- Forks
- 1.4k
- Merge medio
- 1 d 3 h
- PR fusionados (30 d)
- 18
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de larksuite/cli
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
domain/im
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug domain/doc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
auth: a 429 from the Token Endpoint during refresh deletes a still-valid loginPosiblemente ocupada @linye157 la tomó hace 26 días. Abiertobug domain/auth domain/im
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
larksuite/cli#2869 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
domain/core enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
Todos los issues de larksuite/cli
Issues similares
-
test_archive_is_downloaded_after_logout_login doesn't wait for the storage client after loginAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
list_issues and search_issues: inconsistent `fields` allow-lists (`html_url` rejected by list)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
github/github-mcp-server#3960 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
JuliusBrussee/caveman#1594 ·
Los mantenedores suelen responder en 1 día
-
C-bug O-community X-blathers-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
cockroachdb/cockroach#176264 · 1 comentario ·
-
security trivy
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
kubefleet-dev/kubefleet#1068 ·
Los mantenedores suelen responder en 3 días