Non-UTF-8 paths send empty heartbeats on Neovim; g:aw_hostname is not URL-encoded

Aperta Adatta ai principianti
#34 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
vim
Ambito
tooling

Direzione di ricerca

Parti da HTTPPostJson e dal codice che costruisce s:bucket_apiurl; sono gli unici due punti toccati dalla correzione. Riproduci in Neovim 0.9.5 con un percorso come caf\xe9.txt e con let g:aw_hostname impostato a 'my laptop', 'host#1' e 'a/b'. Fatto quando un json_encode che fallisce non invia più un body vuoto e il bucket id è percent-encoded, così che il bucket creato sul server corrisponda a ciò che riporta :AWStatus.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Two smaller request-building bugs found while testing ActivityWatch/aw-watcher-vim#32. Both reproduced on master 4ba86d0 with Neovim 0.9.5.

1. A non-UTF-8 file path or cwd sends empty heartbeats (Neovim only). On Neovim, json_encode fails with E474 ... does not start any UTF-8 character on a path such as caf\xe9.txt. HTTPPostJson has no abort, so curl posts an empty body, and every heartbeat produces an E474 plus a status code 400 error. A non-UTF-8 working directory affects every buffer. Vim does not hit this: its json_encode substitutes U+FFFD, so the heartbeat succeeds with a mangled path.
Fix idea: skip the send when json_encode fails (try/catch), or encode the path lossily first.

2. g:aw_hostname is pasted into URLs without percent-encoding. Each value fails differently:

  • my laptop: curl rejects the URL (exit 3), which is reported as "Failed to connect".
  • host#1: curl drops everything after #, so it creates aw-watcher-vim_host while :AWStatus says running, then every heartbeat gets a 422.
  • a/b: the request gets a 404.

This only matters when the user overrides the hostname, since the default from hostname() is URL-safe.
Fix idea: percent-encode the bucket id when building s:bucket_apiurl.

Lingua principale
Vim Script
Stelle
124
Fork
15
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ActivityWatch/aw-watcher-vim

Tutte le issue di ActivityWatch/aw-watcher-vim

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.