diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-04-13 19:45:44 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-04-13 19:45:44 +0000 |
commit | cfba0c6c4d9a42a5384b61f109836783c0adc8a7 (patch) | |
tree | 79911a62bd2a4a020dd0795c905251bb45da9156 /protocols/SkypeWeb/src/skype_utils.cpp | |
parent | 1fba29f58dee5744dd0266b7368b5c004679c011 (diff) |
SkypeWeb: added removing html from messages
git-svn-id: http://svn.miranda-ng.org/main/trunk@12795 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_utils.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_utils.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index dfb57323c8..bf3fb13fd9 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -94,6 +94,75 @@ time_t CSkypeProto::IsoToUnixTime(const TCHAR *stamp) return (t >= 0) ? t : 0;
}
+struct HtmlEntity
+{
+ const char *entity;
+ char symbol;
+};
+
+const HtmlEntity htmlEntities[] =
+{
+ { "nbsp", ' ' },
+ { "amp", '&' },
+ { "quot", '"' },
+ { "lt", '<' },
+ { "gt", '>' },
+ { "apos", '\'' },
+ { "copy", '©' },
+ // TODO: add more
+};
+
+char *CSkypeProto::RemoveHtml(const char *text)
+{
+ std::string new_string = "";
+ std::string data = text;
+
+ if (data.find("\x1b\xe3\xac\x8d\x1d") != -1)
+ data = "CONVERSATION MEMBERS:" + data.substr(5, data.length() - 5);
+
+ for (std::string::size_type i = 0; i < data.length(); i++)
+ {
+ if (data.at(i) == '<' && data.at(i + 1) != ' ')
+ {
+ i = data.find(">", i);
+ if (i == std::string::npos)
+ break;
+
+ continue;
+ }
+
+ if (data.at(i) == '&') {
+ std::string::size_type begin = i;
+ i = data.find(";", i);
+ if (i == std::string::npos) {
+ i = begin;
+ }
+ else {
+ std::string entity = data.substr(begin + 1, i - begin - 1);
+
+ bool found = false;
+ for (int j = 0; j < SIZEOF(htmlEntities); j++)
+ {
+ if (!stricmp(entity.c_str(), htmlEntities[j].entity))
+ {
+ new_string += htmlEntities[j].symbol;
+ found = true;
+ break;
+ }
+ }
+
+ if (found)
+ continue;
+ else
+ i = begin;
+ }
+ }
+
+ new_string += data.at(i);
+ }
+
+ return mir_strdup(new_string.c_str());
+}
bool CSkypeProto::IsMe(const char *skypeName)
{
|