Params middleware does not decode some strings correctly
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Read the params middleware's URL-decoding path and the wrap-params encoding option described in the issue. Reproduce the Shift_JIS example, compare the decoder behavior, and confirm completion when the encoded parameter yields the original Japanese string without breaking existing parameter parsing.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi James, thanks for the continued work on maintaining ring.
Just want to throw this issue out there in case anyone else stumbles upon the same issue, plus gathering some feedback.
In our project, we were dealing with non utf-8 encoded forms (Shift_JIS to be specific), and found that the params middleware is garbling the incoming string, even though we were using the wrap-params middleware with the Shift_JIS option e.g. (param/wrap-params {:encoding "Shift_JIS"})
Looking at the source code deeper inside, I see that java.net.URLDecoder is being used for parsing, and that java.net.URLDecoder does not decode some non utf-8 strings correctly, while org.apache.commons.codec.net.URLCodec can, illustrated in below snippet.
;; "モジバケコワイ", URL encoded with Shif_JIS by the browser
"%83%82%83W%83o%83P%83R%83%8F%83C"
(import [java.net URLDecoder])
(URLDecoder/decode "%83%82%83W%83o%83P%83R%83%8F%83C" "Shift-JIS")
;; => "モ�W�o�P�Rワ�C"
(import [org.apache.commons.codec.net URLCodec])
(let [codec (URLCodec. "Shift-JIS")]
(.decode codec "%83%82%83W%83o%83P%83R%83%8F%83C" "Shift-JIS"))
;; => "モジバケコワイ"
We came up with 2 work arounds for this issue:
- Use org.apache.commons.codec.net.URLCodec instead of java.net.URLDecoder for decoding URL encoded parameteres
- Use a form with an enctype of multipart/form-data so that nothing gets encoded and thus avoid the problem entirely
Would appreciate the if I can get feed back on:
- Which of the above workaround is preferable?
- Would you be interested in a PR that replaces the decoder used in the params middleware with org.apache.commons.codec.net URLCodec?
Thanks!
- Lingua principale
- Clojure
- Stelle
- 3.9k
- Fork
- 528
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun 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 ring-clojure/ring
-
Typo in wrap-nested-params docstringForse già presa @dajiaohuang l’ha presa 3 giorni fa. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
ring-clojure/ring#546 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
ring-clojure/ring#544 · 3 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
ring-clojure/ring#542 · 5 commenti · 2 reazioni ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
ring-clojure/ring#541 · 3 commenti ·
-
[ring-jetty-adapter] No control over exceptions thrown when obtaining item from ISeq response bodyAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
ring-clojure/ring#531 · 4 commenti ·
Tutte le issue di ring-clojure/ring
Issue simili
-
Sessions are never closedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno