diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-12-11 14:13:44 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-12-11 14:13:44 +0000 |
commit | f42588bbc90058000b272265593c0fd9f83590a7 (patch) | |
tree | a8561483ebd86518dba0f8c8ebf9ee2ae9d95aa7 /protocols/FacebookRM | |
parent | 1ad0cdf13bb5c22a08daa9398f51764eb14f69f0 (diff) |
Facebook: Fix login for users from Belgium; version bump
By parsing "deferred cookies" set by JavaScript.
git-svn-id: http://svn.miranda-ng.org/main/trunk@15837 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 32 | ||||
-rw-r--r-- | protocols/FacebookRM/src/constants.h | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/version.h | 4 |
3 files changed, 30 insertions, 8 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 34fcaa7735..2a2fe90333 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -584,9 +584,9 @@ char* facebook_client::load_cookies() { ScopedLock s(cookies_lock_); - std::string cookieString = "isfbe=false;"; + std::string cookieString; - if (!cookies.empty()) + if (!cookies.empty()) { for (std::map< std::string, std::string >::iterator iter = cookies.begin(); iter != cookies.end(); ++iter) { cookieString.append(iter->first); @@ -594,6 +594,7 @@ char* facebook_client::load_cookies() cookieString.append(iter->second); cookieString.append(1, ';'); } + } return mir_strdup(cookieString.c_str()); } @@ -607,8 +608,9 @@ void facebook_client::store_headers(http::response* resp, NETLIBHTTPHEADER* head std::string header_value = headers[i].szValue; if (header_name == "Set-Cookie") { - std::string cookie_name = header_value.substr(0, header_value.find("=")); - std::string cookie_value = header_value.substr(header_value.find("=") + 1, header_value.find(";") - header_value.find("=") - 1); + std::string::size_type pos = header_value.find("="); + std::string cookie_name = header_value.substr(0, pos); + std::string cookie_value = header_value.substr(pos + 1, header_value.find(";", pos) - pos - 1); if (cookie_value == "deleted") cookies.erase(cookie_name); @@ -738,7 +740,27 @@ bool facebook_client::login(const char *username, const char *password) cookies["datr"] = device; // Get initial cookies - flap(REQUEST_HOME); + 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); + } } // Prepare login data diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h index 1c9e0f5453..8e5fd73fbf 100644 --- a/protocols/FacebookRM/src/constants.h +++ b/protocols/FacebookRM/src/constants.h @@ -38,7 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_SERVER_REGULAR "www.facebook.com"
#define FACEBOOK_SERVER_MOBILE "mbasic.facebook.com"
#define FACEBOOK_SERVER_CHAT "%s-%s.facebook.com"
-#define FACEBOOK_SERVER_LOGIN "login.facebook.com"
+#define FACEBOOK_SERVER_LOGIN "www.facebook.com"
#define FACEBOOK_SERVER_APPS "apps.facebook.com"
#define FACEBOOK_SERVER_DOMAIN "facebook.com"
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index 5d9735ae66..63bf5f3e18 100644 --- a/protocols/FacebookRM/src/version.h +++ b/protocols/FacebookRM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 #define __RELEASE_NUM 11 -#define __BUILD_NUM 4 +#define __BUILD_NUM 5 #include <stdver.h> @@ -11,4 +11,4 @@ #define __AUTHOR "Michal Zelinka, Robert P\xf6" "sel" #define __AUTHOREMAIL "robyer@seznam.cz" #define __AUTHORWEB "http://miranda-ng.org/p/Facebook/" -#define __COPYRIGHT "© 2009-11 Michal Zelinka, 2011-15 Robert P\xf6" "sel" +#define __COPYRIGHT "© 2011-15 Robert P\xf6" "sel, 2009-11 Michal Zelinka" |