From af10723abafc00db6a77edd299cea1fc7c6822ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Sat, 30 May 2015 21:31:29 +0000 Subject: 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 --- protocols/FacebookRM/src/proto.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'protocols') 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) -- cgit v1.2.3