Commit 76e92e8
committed
Exclude decoded params on invalid URL encoding
Given the squashing of all exceptions in form-decode-str, the prior
implementation of form-decode would return nil keys and/or values for
parameters which failed to URL decode. With this change the
parameters are silently dropped.
Including nil parameters creates problems for downstream
middleware (e.g. ring.middleware.nested-params -- see
ring-clojure/ring#243) which are not expecting them, and has no basis
in the spec (https://url.spec.whatwg.org/#urlencoded-parsing).
One can second guess the decision to catch all decoding
exceptions (see #22) rather than allowing them to bubble up (and thus
potentially allow the application to return an error status), but that
decision being what it is, it seems most in the spirit of the library
to drop the invalid parameters.
For completeness, here are the (known) URL decoding failure cases:
- Illegal hex values in % escape pattern
- Incomplete % escape pattern1 parent 02f724b commit 76e92e8
2 files changed
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
146 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
147 | 150 | | |
148 | 151 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
0 commit comments