WebSocket close reasons can be truncated inside a UTF-8 character
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- python
- Domaine
- networking
Piste de recherche
Lisez WebSocket.close() et _fail(), où l’issue signale le même comportement de découpage en octets. Exécutez les tests WebSocket existants et ajoutez des tests pour les raisons multioctets à la limite de 123 octets, y compris les exemples fournis et les contrôles qui doivent réussir. Le travail est terminé lorsque la troncature respecte la limite en octets sans couper un caractère UTF-8 dans l’un ou l’autre des deux chemins de fermeture.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
On main 851b0080cacb03ec38da828160681c64f8d0b29c, WebSocket.close() constructs the close frame with reason.encode("utf-8")[:123]. This keeps the control frame within the byte limit but can split a multibyte character, producing an invalid UTF-8 close reason.
For example, await socket.close(1000, "é" * 62) sends a 123-byte reason ending in the first byte of the final character. A local server that unmasks the close frame and decodes payload[2:] gets UnicodeDecodeError at byte 122. "😀" * 31 and "a" * 122 + "é" also reproduce it. ASCII reasons and multibyte reasons ending on a complete-character boundary are controls that pass.
RFC 6455 section 5.5.1 specifies UTF-8 data after the close code, and section 8.1 requires a peer to fail the connection for invalid UTF-8. Thus a normal application close can become a protocol failure. The same byte slicing appears in _fail().
Validation used Python 3.13.17 on Linux and a local asyncio TCP server, with no external service. The existing 19 WebSocket tests pass when run in isolation. Eight additional close-reason cases against unchanged source produce three failures and five passing controls. These are isolated networking tests, not the repository's complete checks, installed-package test-plugin validation, or mobile tests. The active feat/runtime branch has the same WebSocket source.
Would a fix that preserves the existing truncation behavior but cuts only at complete UTF-8 boundaries be welcome? If so, could you assign this to me before I prepare a PR, following the contribution guide?
This was found during source review and reproduced with constructed examples, not a production incident. AI assistance was used for investigation and local reproduction. No production-source changes have been made.
- Langage dominant
- Python
- Étoiles
- 131
- Forks
- 22
- Merge moyen
- 3 j 2 h
- PR mergées (30 j)
- 5
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de pythonnative/pythonnative
-
Add an API reference page for QueryClient and QuerySnapshotPeut-être pris @glenlouis8 l’a pris il y a 17 jours. Ouvertedocumentation good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
pythonnative/pythonnative#95 · 1 commentaire · 1 personne assignée ·
-
Cover diagnostic warning retention and reset behavior with testsPeut-être pris @glenlouis8 l’a pris il y a 17 jours. Ouvertegood first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
pythonnative/pythonnative#94 · 1 commentaire · 1 personne assignée ·
-
Test icon generation fallbacks when Pillow is unavailablePeut-être pris @glenlouis8 l’a pris il y a 17 jours. Ouvertegood first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
pythonnative/pythonnative#93 · 1 commentaire · 1 personne assignée ·
-
enhancement
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
pythonnative/pythonnative#122 ·
-
Android CI fails when SDK or Robolectric downloads arrive corruptPeut-être pris @TheoGoulart333 l’a pris il y a 6 jours. Ouvertebug
Difficulté 3/5 1-2 jours Accessibilité débutants 68/100
pythonnative/pythonnative#119 · 2 commentaires · 1 personne assignée ·
Toutes les issues de pythonnative/pythonnative
Issues similaires
-
Contributing instructionsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
dbt-labs/spark-utils#51 ·
-
bug pydanty:is-working
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
pydantic/pydantic-ai#13444 ·
Les mainteneurs répondent en général sous 1 jour
-
good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
good first issue help wanted
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
-
changelog investigate
Difficulté 1/5 Moins d'une heure Accessibilité débutants 68/100
ramnes/notion-sdk-py#502 ·