bitemyapp / bitemyapp/twitcurl

URL encoding error

Open
#52 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
C
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

```
What steps will reproduce the problem?
1. Call twitCurl::search with a hashtag search string

What is the expected output? What do you see instead?

Expected output is the search results. Actual output is an authentication error.

What version of the product are you using? On what operating system?

r122 on Windows 8 x64

Please provide any additional information below.

oauth_signature needs to be generated with the unencoded URL which is done
correctly, however the parameters then need to be encoded before being passed
to cURL.

Here's what I've done to work around this and I can now search with hashtags:

std::vector &split(const std::string &s, char delim,
std::vector &elems) {
std::stringstream ss(s);
std::string item("");
while (std::getline(ss, item, delim)) {
if (!item.empty())
elems.push_back(item);
}
return elems;
}

bool twitCurl::performGet( const std::string& getUrl )

...

std::string request("");
/* Check for parameters */
if (getUrl.find('?')!=std::string::npos)
{
std::size_t divide = getUrl.find_first_of('?')+1;
std::string encodedparams("");
std::string params=getUrl.substr(divide);
std::vector vparams;
split(params,'&',vparams);
for (unsigned int i=0;i0) encodedparams+="&";
std::size_t pos = vparams[i].find('=');
if (pos!=std::string::npos)
encodedparams+=vparams[i].substr(0,pos+1)+urlencode(vparams[i].substr(pos+1));
else
encodedparams+=vparams[i];
}
request=getUrl.substr(0,divide)+encodedparams;
}
else
request=getUrl;

/* Set http request and url */
curl_easy_setopt( m_curlHandle, CURLOPT_HTTPGET, 1 );
curl_easy_setopt( m_curlHandle, CURLOPT_URL, request.c_str() );
```

Original issue reported on code.google.com by `sbd...@gmail.com` on 18 Sep 2013 at 1:36

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at twitCurl::search and follow its request into performGet, especially the parameter handling before CURLOPT_URL is set. Compare the reported hashtag-search authentication failure with the supplied workaround. Done means hashtag searches return results without the authentication error on the reported configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.