-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Including = symbol in JSON post body causes body to become truncated #77
Comments
I'm seeing that this works if the = is encoded as %3d. |
I caught this issue today as well. For those who are curious, the problem is coming from this logic: Line 234 in 7eb9a13
It looks like twurl is doing this by default and there's no way to skip this which is very confusing and doesn't make sense to me having this logic for all POST data.
Exactly... curl doesn't do anything like this. Probably, it's difficult to just remove this logic as it will potentially require a bunch of documentation fix (on developer.twitter.com) and other critical stuff, but we should have a logic to check if a I also noticed there's a Lines 240 to 246 in 7eb9a13
but as you can guess it doesn't work because of the parse, again... Well, there's a logic that supposed to pass a "raw" body data (was introduced in #60): twurl/lib/twurl/oauth_client.rb Lines 111 to 112 in bac93af
but it only gets a "key" even though rest of the text after |
FYI, I looked at the code further (I'm Ruby beginner though..) and noticed that this fix isn't that easy as I thought initially. Since twurl is using OptionParser in order to parse command-line args, it reads args one by one with an actual input order. That means, if a user set options like this oder:
Lines 231 to 238 in 7eb9a13
Maybe we can do pattern matching using twurl/lib/twurl/oauth_client.rb Lines 111 to 112 in bac93af
to something like this: elsif request.content_type && options.data
data = ''
if options.data.length == 1 && options.data.values.first == nil
data += options.data.keys.first
else
options.data.each_with_index do |(key, value), i|
data += (i == 0 ? '' : '&') + key.to_s + (value == nil ? '' : '=' + value.to_s)
end
end
request.body = data |
The fix is merged into master. |
Currently, including the = symbol inside any JSON body posted to the API via twurl causes the body content to be truncated at the = symbol, and the request will subsequently fail. This occurs even with the Content-Type set to application/json.
The text was updated successfully, but these errors were encountered: