diff options
author | NightFox <0x4E69676874466F78@users.noreply.github.com> | 2019-07-12 00:01:36 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-07-12 18:08:48 +0300 |
commit | 36857f0695a39070d10ebc5b68f0d54560e07039 (patch) | |
tree | ef40d85b4da364a8cbb18c88f1eda604e531a26d | |
parent | 768c9c82b193b1031ea8ee9f2cb41404d48310e7 (diff) |
Improvement logic regular expressions for skype_oauth.cpp
Immunity to extraneous classes, attributes, spaces
But the best way is to use a good html parser
-rw-r--r-- | protocols/SkypeWeb/src/skype_oauth.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/protocols/SkypeWeb/src/skype_oauth.cpp b/protocols/SkypeWeb/src/skype_oauth.cpp index 290a70fe83..85327edf91 100644 --- a/protocols/SkypeWeb/src/skype_oauth.cpp +++ b/protocols/SkypeWeb/src/skype_oauth.cpp @@ -30,7 +30,7 @@ void CSkypeProto::OnOAuthStart(const NETLIBHTTPREQUEST *response) std::map<std::string, std::string> scookies; std::string content = response->pData; - regex = "<input type=\"hidden\" name=\"PPFT\" id=\"i0327\" value=\"(.+?)\"/>"; + regex = "<input.+?type=\"hidden\".+?name=\"PPFT\".+?id=\"i0327\".+?value=\"(.+?)\".*?/>"; if (!std::regex_search(content, match, regex)) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); @@ -66,8 +66,8 @@ void CSkypeProto::OnOAuthAuthorize(const NETLIBHTTPREQUEST *response) std::string content = response->pData; std::smatch match; - if (!std::regex_search(content, match, std::regex("<input type=\"hidden\" name=\"t\" id=\"t\" value=\"(.+?)\">"))) { - if (!std::regex_search(content, match, std::regex("<input type=\"hidden\" name=\"ipt\" id=\"ipt\" value=\"(.+?)\">"))) { + if (!std::regex_search(content, match, std::regex("<input.+?type=\"hidden\".+?name=\"t\".+?id=\"t\".+?value=\"(.+?)\".*?>"))) { + if (!std::regex_search(content, match, std::regex("<input.+?type=\"hidden\".+?name=\"ipt\".+?id=\"ipt\".+?value=\"(.+?)\".*?>"))) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); return; @@ -90,7 +90,7 @@ void CSkypeProto::OnOAuthEnd(const NETLIBHTTPREQUEST *response) std::smatch match; std::string content = response->pData; - regex = "<input type=\"hidden\" name=\"skypetoken\" value=\"(.+?)\"/>"; + regex = "<input.+?type=\"hidden\".+?name=\"skypetoken\".+?value=\"(.+?)\".*?/>"; if (!std::regex_search(content, match, regex)) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); @@ -98,7 +98,7 @@ void CSkypeProto::OnOAuthEnd(const NETLIBHTTPREQUEST *response) } std::string token = match[1]; setString("TokenSecret", token.c_str()); - regex = "<input type=\"hidden\" name=\"expires_in\" value=\"(.+?)\"/>"; + regex = "<input.+?type=\"hidden\".+?name=\"expires_in\".+?value=\"(.+?)\".*?/>"; if (std::regex_search(content, match, regex)) { std::string expiresIn = match[1]; |