Non-ASCII characters are corrupted when importing properties content with the env: prefix
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- java, spring-boot
- Ambito
- backend
Direzione di ricerca
Inizia da SystemEnvironmentConfigDataResource#load, dove l’issue indica che la stringa della variabile d’ambiente viene codificata in UTF-8 prima di essere passata al loader delle properties. Leggi i test correlati SystemEnvironmentConfigData* e aggiungi copertura per contenuti properties con caratteri non ASCII importati con il prefisso env:. Il lavoro è completato quando il valore importato conserva i caratteri originali senza richiedere un’indicazione di codifica.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
SystemEnvironmentConfigDataResource turns the environment variable value into bytes with content.getBytes(StandardCharsets.UTF_8), but then calls loader.load(name, resource, this.encoding) with encoding == null unless the [encoding=...] hint is used. OriginTrackedPropertiesLoader then decodes with its default ISO-8859-1, so any non-ASCII character in a .properties-style variable is corrupted.
Since the environment variable is already a String, there is no file encoding involved, and the bytes Spring Boot produces itself are always UTF-8.
Spring Boot 4.1.2
MY_CONF='greeting=Grüße' java -jar app.jar --spring.config.import=env:MY_CONF
environment.getProperty("greeting") -> "Grüße" (expected "Grüße")
The same content imported as YAML (env:MY_CONF[.yaml]) is read correctly. Adding [encoding=utf-8] works around the problem, but users have no reason to expect they need it for an in-memory string.
Possible fix: in SystemEnvironmentConfigDataResource#load, default to the charset the content was encoded with:
private Charset getEncoding() {
return (this.encoding != null) ? this.encoding : StandardCharsets.UTF_8;
}
I verified this end to end: I ran the packaged app as a separate process with the variable set and read the value over HTTP. With 4.1.2 the bytes are 47 72 c3 83 c2 bc .... With a locally built spring-boot jar including the change above, the result is Grüße (47 72 c3 bc c3 9f 65). The existing SystemEnvironmentConfigData* tests still pass. I'm happy to submit a PR with a test.
- Lingua principale
- Java
- Stelle
- 81.8k
- Fork
- 43.5k
- Merge medio
- 3g 13h
- PR unite (30g)
- 90
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di spring-projects/spring-boot
-
status: waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
spring-projects/spring-boot#52651 ·
I maintainer di solito rispondono entro 2 giorni
-
JavaLoggingSystem.getLoggerConfiguration does not map ROOT and creates unknown loggers on lookupApertastatus: waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
spring-projects/spring-boot#52646 ·
I maintainer di solito rispondono entro 2 giorni
-
Maven process-test-aot only copies META-INF/native-image of the generated resources so the Logback configuration is lost in native testsForse già presa @tchowdhury101 l’ha presa 4 giorni fa. Apertatype: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
spring-projects/spring-boot#52301 · 4 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
for: team-meeting status: waiting-for-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
spring-projects/spring-boot#52295 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
Add a How-To to explain how to configure logging of AOT processingForse di nuovo libera @dana-stc l’ha presa 30 giorni fa e non c’è nessuna pull request aperta. Apertastatus: team-only type: documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
spring-projects/spring-boot#52092 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di spring-projects/spring-boot
Issue simili
-
hermes-queue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
chrisalunlloyd2-sudo/mindpalace#349 ·
I maintainer di solito rispondono entro 1 giorno
-
Retry-After parser accepts invalid delay-seconds valuesForse già presa @Dhruvraj-Rana l’ha presa oggi. ApertaBug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
open-telemetry/opentelemetry-java#9018 ·
I maintainer di solito rispondono entro 2 giorni
-
bug priority: medium Review effort [1-5]: 2 status: needs-triage type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
carlos-emr/carlos#5818 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue help wanted tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
appmonster007/kmip-adapter#100 ·
-
accepted good first issue java
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno