diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-05-30 21:31:29 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-05-30 21:31:29 +0000 |
commit | af10723abafc00db6a77edd299cea1fc7c6822ab (patch) | |
tree | 80ee26a7a8ad6e6c79d8118b40b74bb5ba031277 /protocols/FacebookRM | |
parent | 1a3d8165a7ea32cb104cbcc0509101f809e6e6a0 (diff) |
Facebook: Fix opening notifications with URLs linking to developers.facebook.com domain
If someone know any other special subdomain that Facebook use, let me know.
git-svn-id: http://svn.miranda-ng.org/main/trunk@13915 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 188df14797..c1181c307c 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -876,25 +876,30 @@ void FacebookProto::OpenUrlThread(void *p) { std::string FacebookProto::PrepareUrl(std::string url) { std::string::size_type pos = url.find(FACEBOOK_SERVER_DOMAIN); bool isFacebookUrl = (pos != std::string::npos); - bool isRelativeUrl = (url.substr(0, 4) != "http"); + bool isAbsoluteUrl = (url.find("://") != std::string::npos); - if (isFacebookUrl || isRelativeUrl) { - - // Make realtive url - if (!isRelativeUrl) { - url = url.substr(pos + mir_strlen(FACEBOOK_SERVER_DOMAIN)); - - // Strip eventual port - pos = url.find("/"); - if (pos != std::string::npos && pos != 0) - url = url.substr(pos); - } - - // Make absolute url - url = HTTP_PROTO_SECURE + facy.get_server_type() + url; + // Do nothing with absolute non-Facebook URLs + if (isAbsoluteUrl && !isFacebookUrl) + return url; + + // Transform absolute URL to relative + if (isAbsoluteUrl) { + // Check and ignore special subdomains + std::string subdomain = utils::text::source_get_value(&url, 2, "://", "."FACEBOOK_SERVER_DOMAIN); + if (subdomain == "developers") + return url; + + // Make relative url + url = url.substr(pos + mir_strlen(FACEBOOK_SERVER_DOMAIN)); + + // Strip eventual port + pos = url.find("/"); + if (pos != std::string::npos && pos != 0) + url = url.substr(pos); } - return url; + // URL is relative now, make and return absolute + return HTTP_PROTO_SECURE + facy.get_server_type() + url; } void FacebookProto::OpenUrl(std::string url) |