From d482eb3eec3f0ff0dc14e1b98351b61662bdbbb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 24 Dec 2014 11:27:08 +0000 Subject: Facebook: Better check for unexpected redirect at login git-svn-id: http://svn.miranda-ng.org/main/trunk@11604 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/communication.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'protocols') diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index df86bfed9d..d8d91399e4 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -947,9 +947,15 @@ bool facebook_client::login(const char *username, const char *password) case HTTP_CODE_FOUND: // Found and redirected somewhere { if (resp.headers.find("Location") != resp.headers.end()) { - std::string url = (this->https_ ? "https://"FACEBOOK_SERVER_REGULAR"/" : "http://"FACEBOOK_SERVER_REGULAR"/"); - - if (resp.headers["Location"] != url) { + std::string redirectUrl = resp.headers["location"]; + std::string expectedUrl = (this->https_ ? "https://"FACEBOOK_SERVER_REGULAR"/" : "http://"FACEBOOK_SERVER_REGULAR"/"); + + // Remove eventual parameters + std::string::size_type pos = redirectUrl.rfind("?"); + if (pos != std::tstring::npos) + redirectUrl = redirectUrl.substr(0, pos); + + if (redirectUrl != expectedUrl) { // Unexpected redirect, but we try to ignore it - maybe we were logged in anyway parent->debugLogA(" ! ! Login error: Unexpected redirect: %s", resp.headers["Location"].c_str()); } -- cgit v1.2.3