Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

SyntaxError for files with wrong encoding

Aperta
#517 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
ruby
Ambito
tooling

Direzione di ricerca

Inizia da Psych.safe_load e dalla chiamata di parsing segnalata in psych.rb:456, quindi riproduci il problema con il file allegato example_file.txt e analizzane la codifica. L'issue non indica un test né una condizione di accettazione precisa; per completarla sarebbe necessario concordare un comportamento per gli input non UTF-8 e aggiungere un controllo di regressione per quell'esempio.

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

Descrizione

I have multiple files that just look fine with editors (gedit, sublime, vim) but produce the following error message when loaded by Psych:

Psych.safe_load(file)
/usr/local/lib/ruby/3.0.0/psych.rb:456:in `parse': (<unknown>): invalid trailing UTF-8 octet at line 1 column 1 (Psych::SyntaxError)

A file example can be found here (renamed as attaching a .yaml file is not supported). I am not that familiar with character encoding, but the file seems to get interpreted as UTF-8 while it actually isn't. isutf8 returns metal_copper (1).yaml: line 87, char 12, byte 1497: After a first byte between E1 and EC, expecting the 2nd byte between 80 and BF. on the file example.

I do not know how editor software today handle this topic, but it sure would be desirable to have Psych parse files in the way as shown in common editors. From googling the error message it seems I am not the only one who had problems with that and it seem to produce problem now and then for users/project that use Psych.

Lingua principale
Ruby
Stelle
597
Fork
223
Merge medio
14m
PR unite (30g)
1

Preparare l'ambiente

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 ruby/psych

Tutte le issue di ruby/psych

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.