summaryrefslogtreecommitdiff
path: root/protocols/Skype/src
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-12-23 19:45:46 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-12-23 19:45:46 +0000
commitafc16fc2d120e780220cddc03350122ad8e672fc (patch)
tree5ba0b1bb3ced704a516e0c1df59a1e736aa2e334 /protocols/Skype/src
parent5dec14aae90a4ea4f16a6e2b57d52375599b90c0 (diff)
remove html tags (thx Robyer)
git-svn-id: http://svn.miranda-ng.org/main/trunk@2819 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src')
-rw-r--r--protocols/Skype/src/skype.h1
-rw-r--r--protocols/Skype/src/skype_events.cpp2
-rw-r--r--protocols/Skype/src/skype_proto.h19
-rw-r--r--protocols/Skype/src/skype_utils.cpp100
4 files changed, 95 insertions, 27 deletions
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h
index e9011fc3ec..8e357b1efd 100644
--- a/protocols/Skype/src/skype.h
+++ b/protocols/Skype/src/skype.h
@@ -6,6 +6,7 @@
#include <malloc.h>
#include <shlwapi.h>
#include <tlhelp32.h>
+#include <string>
//#pragma warning(push)
//# pragma warning(disable:4312)
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp
index 9b1e442133..7ae3583906 100644
--- a/protocols/Skype/src/skype_events.cpp
+++ b/protocols/Skype/src/skype_events.cpp
@@ -109,7 +109,7 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R
(DWORD)timestamp,
sid,
nick,
- text);
+ CSkypeProto::RemoveHtml(text));
}
else
{
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index bd2f8ed109..cce9a776f2 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -115,6 +115,23 @@ const SettingItem setting[]={
{LPGENT("About"), "About", DBVT_WCHAR, LI_STRING}
};
+struct HtmlEntity
+{
+ const char *entity;
+ char symbol;
+};
+
+const HtmlEntity htmlEntities[]={
+ {"nbsp", ' '},
+ {"amp", '&'},
+ {"quot", '"'},
+ {"lt", '<'},
+ {"gt", '>'},
+ {"apos", '\''},
+ {"copy", '©'},
+ // TODO: add more
+};
+
struct InviteChatParam
{
char *id;
@@ -358,6 +375,8 @@ protected:
static char CharBase64[];
static ULONG Base64Encode(char *inputString, char *outputBuffer, SIZE_T nMaxLength);
+ static char *RemoveHtml(char *data);
+
// instances
static LIST<CSkypeProto> instanceList;
static int CompareProtos(const CSkypeProto *p1, const CSkypeProto *p2);
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp
index 5fdcb0dff1..008f295cae 100644
--- a/protocols/Skype/src/skype_utils.cpp
+++ b/protocols/Skype/src/skype_utils.cpp
@@ -1,32 +1,32 @@
#include "skype_proto.h"
wchar_t* CSkypeProto::LogoutReasons[] =
-{
- LPGENW("LOGOUT_CALLED") /* LOGOUT_CALLED */,
- LPGENW("HTTPS_PROXY_AUTH_FAILED") /* HTTPS_PROXY_AUTH_FAILED */,
- LPGENW("SOCKS_PROXY_AUTH_FAILED") /* SOCKS_PROXY_AUTH_FAILED */,
- LPGENW("P2P_CONNECT_FAILED") /* P2P_CONNECT_FAILED */,
- LPGENW("SERVER_CONNECT_FAILED") /* SERVER_CONNECT_FAILED */,
- LPGENW("SERVER_OVERLOADED") /* SERVER_OVERLOADED */,
- LPGENW("DB_IN_USE") /* DB_IN_USE */,
- LPGENW("Invalid skypename") /* INVALID_SKYPENAME */,
- LPGENW("Invalid email") /* INVALID_EMAIL */,
- LPGENW("Unacceptable password") /* UNACCEPTABLE_PASSWORD */,
- LPGENW("SKYPENAME_TAKEN") /* SKYPENAME_TAKEN */,
- LPGENW("REJECTED_AS_UNDERAGE") /* REJECTED_AS_UNDERAGE */,
- LPGENW("NO_SUCH_IDENTITY") /* NO_SUCH_IDENTITY */,
- LPGENW("Incorrect password") /* INCORRECT_PASSWORD */,
- LPGENW("Too many login attempts") /* TOO_MANY_LOGIN_ATTEMPTS */,
- LPGENW("PASSWORD_HAS_CHANGED") /* PASSWORD_HAS_CHANGED */,
- LPGENW("PERIODIC_UIC_UPDATE_FAILED") /* PERIODIC_UIC_UPDATE_FAILED */,
- LPGENW("DB_DISK_FULL") /* DB_DISK_FULL */,
- LPGENW("DB_IO_ERROR") /* DB_IO_ERROR */,
- LPGENW("DB_CORRUPT") /* DB_CORRUPT */,
- LPGENW("DB_FAILURE") /* DB_FAILURE */,
- LPGENW("INVALID_APP_ID") /* INVALID_APP_ID */,
- LPGENW("APP_ID_FAILURE") /* APP_ID_FAILURE */,
- LPGENW("UNSUPPORTED_VERSION") /* UNSUPPORTED_VERSION */,
- LPGENW("ATO (Account TakeOver) detected, account blocked") /* ATO_BLOCKED */,
+{
+ LPGENW("LOGOUT_CALLED") /* LOGOUT_CALLED */,
+ LPGENW("HTTPS_PROXY_AUTH_FAILED") /* HTTPS_PROXY_AUTH_FAILED */,
+ LPGENW("SOCKS_PROXY_AUTH_FAILED") /* SOCKS_PROXY_AUTH_FAILED */,
+ LPGENW("P2P_CONNECT_FAILED") /* P2P_CONNECT_FAILED */,
+ LPGENW("SERVER_CONNECT_FAILED") /* SERVER_CONNECT_FAILED */,
+ LPGENW("SERVER_OVERLOADED") /* SERVER_OVERLOADED */,
+ LPGENW("DB_IN_USE") /* DB_IN_USE */,
+ LPGENW("Invalid skypename") /* INVALID_SKYPENAME */,
+ LPGENW("Invalid email") /* INVALID_EMAIL */,
+ LPGENW("Unacceptable password") /* UNACCEPTABLE_PASSWORD */,
+ LPGENW("SKYPENAME_TAKEN") /* SKYPENAME_TAKEN */,
+ LPGENW("REJECTED_AS_UNDERAGE") /* REJECTED_AS_UNDERAGE */,
+ LPGENW("NO_SUCH_IDENTITY") /* NO_SUCH_IDENTITY */,
+ LPGENW("Incorrect password") /* INCORRECT_PASSWORD */,
+ LPGENW("Too many login attempts") /* TOO_MANY_LOGIN_ATTEMPTS */,
+ LPGENW("PASSWORD_HAS_CHANGED") /* PASSWORD_HAS_CHANGED */,
+ LPGENW("PERIODIC_UIC_UPDATE_FAILED") /* PERIODIC_UIC_UPDATE_FAILED */,
+ LPGENW("DB_DISK_FULL") /* DB_DISK_FULL */,
+ LPGENW("DB_IO_ERROR") /* DB_IO_ERROR */,
+ LPGENW("DB_CORRUPT") /* DB_CORRUPT */,
+ LPGENW("DB_FAILURE") /* DB_FAILURE */,
+ LPGENW("INVALID_APP_ID") /* INVALID_APP_ID */,
+ LPGENW("APP_ID_FAILURE") /* APP_ID_FAILURE */,
+ LPGENW("UNSUPPORTED_VERSION") /* UNSUPPORTED_VERSION */,
+ LPGENW("ATO (Account TakeOver) detected, account blocked") /* ATO_BLOCKED */,
LPGENW("Logout from another instance") /* REMOTE_LOGOUT */,
LPGENW("") /* ACCESS_TOKEN_RENEWAL_FAILED */
};
@@ -524,4 +524,52 @@ ULONG CSkypeProto::Base64Encode(char *inputString, char *outputBuffer, SIZE_T nM
outputBuffer[outpos] = 0;
return outpos;
+}
+
+char *CSkypeProto::RemoveHtml(char *text)
+{
+ std::string new_string = "";
+ std::string data = text;
+
+ 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);
+ }
+
+ ::mir_free(text);
+ return ::mir_strdup(new_string.c_str());
} \ No newline at end of file