1 --- src/libcmis/oauth2-providers.cxx
2 +++ src/libcmis/oauth2-providers.cxx
4 * instead of those above.
9 #include <libxml/HTMLparser.h>
10 #include <libxml/xmlreader.h>
13 #define HTML_PARSE_RECOVER 0
18 +// See <https://url.spec.whatwg.org/#concept-urlencoded-byte-serializer>:
19 +void addXWwwFormUrlencoded(std::string * buffer, std::string const & data) {
21 + for (string::const_iterator i = data.begin(); i != data.end(); ++i) {
22 + unsigned char c = static_cast<unsigned char>(*i);
23 + if (c == ' ' || c == '*' || c == '-' || c == '.' || (c >= '0' && c <= '9')
24 + || (c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z'))
26 + *buffer += static_cast<char>(c);
28 + static const char hex[16] = {
29 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
31 + *buffer += hex[c >> 4];
32 + *buffer += hex[c & 0xF];
39 string OAuth2Providers::OAuth2Gdrive( HttpSession* session, const string& authUrl,
40 const string& username, const string& password )
45 loginEmailPost += "Email=";
46 - loginEmailPost += string( username );
47 + addXWwwFormUrlencoded(&loginEmailPost, username);
49 istringstream loginEmailIs( loginEmailPost );
54 loginPasswdPost += "Passwd=";
55 - loginPasswdPost += string( password );
56 + addXWwwFormUrlencoded(&loginPasswdPost, password);
58 istringstream loginPasswdIs( loginPasswdPost );
59 string loginPasswdRes;