diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-12-16 11:43:35 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-12-16 11:43:35 +0000 |
commit | a28a6ed80c01d5d1e000249e67125ac7dd4c0b8d (patch) | |
tree | 0cad6062fec118a165b695881ed03f2825af3a30 /protocols/FacebookRM/src | |
parent | bfd83935257964efceccbdbb526f1cb76b174544 (diff) |
Facebook: Fix login for some other people too (parsing also differently specified cookies)
git-svn-id: http://svn.miranda-ng.org/main/trunk@15873 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 047a71a0d9..98e49ae0d9 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -727,6 +727,27 @@ void loginError(FacebookProto *proto, std::string error_str) { proto->facy.client_notify(buf); } +void parseJsCookies(const std::string &search, const std::string &data, std::map<std::string, std::string> &cookies) { + std::string::size_type pos = 0; + while ((pos = data.find(search, pos)) != std::string::npos) { + pos += search.length(); + + std::string::size_type pos2 = data.find("\",\"", pos); + if (pos2 == std::string::npos) + continue; + + std::string name = data.substr(pos, pos2 - pos); + + pos = pos2 + 3; + pos2 = data.find("\"", pos); + if (pos2 == std::string::npos) + continue; + + std::string value = data.substr(pos, pos2 - pos); + cookies[name] = utils::text::html_entities_decode(value); + } +} + bool facebook_client::login(const char *username, const char *password) { handle_entry("login"); @@ -743,25 +764,9 @@ bool facebook_client::login(const char *username, const char *password) // Get initial cookies http::response resp = flap(REQUEST_LOGIN); - // Also parse deferred cookies set by JavaScript - std::string::size_type pos = 0; - while ((pos = resp.data.find("[\"DeferredCookie\",\"addToQueue\",[],[\"", pos)) != std::string::npos) { - pos += 36; - - std::string::size_type pos2 = resp.data.find("\",\"", pos); - if (pos2 == std::string::npos) - continue; - - std::string name = resp.data.substr(pos, pos2 - pos); - - pos = pos2 + 3; - pos2 = resp.data.find("\"", pos); - if (pos2 == std::string::npos) - continue; - - std::string value = resp.data.substr(pos, pos2 - pos); - cookies[name] = utils::text::html_entities_decode(value); - } + // Also parse cookies set by JavaScript (more variant exists in time, so check all known now) + parseJsCookies("[\"DeferredCookie\",\"addToQueue\",[],[\"", resp.data, cookies); + parseJsCookies("[\"Cookie\",\"setIfFirstPartyContext\",[],[[\"", resp.data, cookies); } // Prepare login data |