Repository navigation
[#345] Hacky solution to wrong headers resolution - #346
marcingrzejszczak wants to merge 1 commit into
Conversation
2edec71 to
e2cb316
Compare
|
NetflixOSS » feign » feign-pull-requests #231 SUCCESS |
|
NetflixOSS » feign » feign-pull-requests #232 SUCCESS |
| Collection<String> resolvedValues = new ArrayList<String>(); | ||
| for (String value : valuesOrEmpty(headers, field)) { | ||
| String resolved = urlDecode(expand(value, encoded)); | ||
| String expandedValueWithEncodedPlus = expand(value, encoded).replaceAll("\\+", "__PLUS__"); |
There was a problem hiding this comment.
does this do the same thing?
String resolved = urlDecode(expand(value, encoded));
resolved = resolved.replace("%2B", "+"); // special case + as that's commonly used in vnd media types.There was a problem hiding this comment.
Actually it doesn't. decode just changes + into (space). I thought that it will be exactly what you wrote.
There was a problem hiding this comment.
you mind reader, you :)
nit: I think "replace" doesn't do regex, so you'd not have to escape the "+" iirc. Otherwise, add a comment like " // special case + as that's commonly used in vnd media types." as that helps set hack-context.
|
@ahus1 I think some version of this hack is good enough (I've seen similar things in the past for %20). wdyt? |
f6c9bba to
25b48eb
Compare
|
NetflixOSS » feign » feign-pull-requests #233 SUCCESS |
|
NetflixOSS » feign » feign-pull-requests #234 SUCCESS |
|
@adriancole @marcingrzejszczak I am fine passing a plus sign "as is". But instead of doing two replace operations, I would have done one replace operation on the original string of "+" to "%2B". Otherwise we would get into trouble if someone uses |
|
hi @ahus1 . I tried that - if I change and then in the test you have |
|
Argh... instead of |
25b48eb to
cdc9a44
Compare
|
NetflixOSS » feign » feign-pull-requests #235 SUCCESS |
|
As read it you are first expanding, then replacing. I think it should be the other way around, as you don't want to replace any plus coming in from an (encoded) variable? |
cdc9a44 to
1cbbcbc
Compare
|
Yup - you're right. Fixed it. |
|
NetflixOSS » feign » feign-pull-requests #236 SUCCESS |
|
+1 with icing on the top. |
|
Had a sleep thought and wondering if we need to be URL encoding post
parameters in the first place. Maybe we were since the infrastructure in
the code wants us to (since it was made for path and query). Might be worth
a thought or TODO to remove URL encoding from this part of the code.
|
I mistakenly advised `@Headers` to follow the encoding rules of `@Body`.
This was a a mistake as in both cases, url encoding is a bad choice, if
the only goal is to prevent accidental variable expansion. For example,
url encoding interferes a lot with content, including messing with '+'
characters, such as exist in "Accept: application/vnd.github.v3+json"
This changes `@Headers` to only address the problem, which where a '{'
literal is desired in a header value. The solution offered here is to
simply repeat "{{" when you desire a '{' literal. For example, if your
header value needs to be literally "{{variable}}", you'd encode it as
"{{{{variable}}".
The impact of this change is limited to those who have already started
using v8.15, and a fast release will occur after merge to limit that.
See #326
Fixes #345
Closes #346
I mistakenly advised `@Headers` to follow the encoding rules of `@Body`.
This was a a mistake as in both cases, url encoding is a bad choice, if
the only goal is to prevent accidental variable expansion. For example,
url encoding interferes a lot with content, including messing with '+'
characters, such as exist in "Accept: application/vnd.github.v3+json"
This changes `@Headers` to only address the problem, which where a '{'
literal is desired in a header value. The solution offered here is to
simply repeat "{{" when you desire a '{' literal. For example, if your
header value needs to be literally "{{variable}}", you'd encode it as
"{{{{variable}}".
The impact of this change is limited to those who have already started
using v8.15, and a fast release will occur after merge to limit that.
See #326
Fixes #345
Closes #346
I mistakenly advised `@Headers` to follow the encoding rules of `@Body`.
This was a a mistake as in both cases, url encoding is a bad choice, if
the only goal is to prevent accidental variable expansion. For example,
url encoding interferes a lot with content, including messing with '+'
characters, such as exist in "Accept: application/vnd.github.v3+json"
This changes `@Headers` to only address the problem, which where a '{'
literal is desired in a header value. The solution offered here is to
simply repeat "{{" when you desire a '{' literal. For example, if your
header value needs to be literally "{{variable}}", you'd encode it as
"{{{{variable}}".
The impact of this change is limited to those who have already started
using v8.15, and a fast release will occur after merge to limit that.
See #326
Fixes #345
Closes #346
fixes #345