jenkinsci / jenkinsci/workflow-basic-steps-plugin

[JENKINS-58835] recognize file's encodings

Aperta
#494 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
component:workflow-basic-steps-plugin imported-jira-issue priority:minor resolution:unresolved
Lingua principale
Java
Stelle
73
Fork
129
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

It would be nice if the readFile basic step could recognize the file's encoding.  (Writing a file with writeFile can store a BOM at the beginning to help in recognizing the character set later, but this must be only a non-default option to preserve backward compatibility with earlier groovy code reading the created files.  This agrees with a rule of thumb "accept liberally, produce conservatively").

There is no need to reinvent the wheel.  Using (and white-listing) groovy.util.CharsetToolkit can make this easy.

 

https://github.com/groovy/groovy-core/blob/GROOVY_2_4_X/src/main/groovy/util/CharsetToolkit.java#L388

 

http://docs.groovy-lang.org/latest/html/api/groovy/util/CharsetToolkit.html#getReader()

 

https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/workflow-basic-steps-2.18/src/main/java/org/jenkinsci/plugins/workflow/steps/ReadFileStep.java

 

---
Originally reported by ilatypov, imported from: recognize file's encodings


  • status: Open
  • priority: Minor
  • component(s): workflow-basic-steps-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20251215-220547

Raw content of original issue

It would be nice if the readFile basic step could recognize the file's encoding.  (Writing a file with writeFile can store a BOM at the beginning to help in recognizing the character set later, but this must be only a non-default option to preserve backward compatibility with earlier groovy code reading the created files.  This agrees with a rule of thumb "accept liberally, produce conservatively").

There is no need to reinvent the wheel.  Using (and white-listing) groovy.util.CharsetToolkit can make this easy.

 

https://github.com/groovy/groovy-core/blob/GROOVY_2_4_X/src/main/groovy/util/CharsetToolkit.java#L388

 

http://docs.groovy-lang.org/latest/html/api/groovy/util/CharsetToolkit.html#getReader()

 

https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/workflow-basic-steps-2.18/src/main/java/org/jenkinsci/plugins/workflow/steps/ReadFileStep.java

 

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con il file referenziato workflow-basic-steps-2.18 ReadFileStep.java e con la documentazione collegata di groovy.util.CharsetToolkit getReader. Determina il comportamento previsto del riconoscimento della codifica per readFile e il comportamento opzionale del BOM di writeFile, quindi verifica che entrambi preservino la compatibilità con le versioni precedenti.

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

Valutazione

Stack tecnologico
java
Ambito
ci-cd
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.