diff options
-rw-r--r-- | MirOTR/MirOTR.vcproj | 4 | ||||
-rw-r--r-- | MirOTR/entities.cpp | 32 | ||||
-rw-r--r-- | MirOTR/entities.h | 2 | ||||
-rw-r--r-- | MirOTR/otr.cpp | 9 | ||||
-rw-r--r-- | MirOTR/svcs_proto.cpp | 36 | ||||
-rw-r--r-- | MirOTR/version.h | 6 | ||||
-rw-r--r-- | lpgen.pl | 2 |
7 files changed, 70 insertions, 21 deletions
diff --git a/MirOTR/MirOTR.vcproj b/MirOTR/MirOTR.vcproj index 686ec3e..cf08188 100644 --- a/MirOTR/MirOTR.vcproj +++ b/MirOTR/MirOTR.vcproj @@ -145,7 +145,7 @@ AdditionalDependencies="libgcrypt.lib libotr.lib Comctl32.lib EkHtml.lib"
LinkIncremental="1"
AdditionalLibraryDirectories=""$(SolutionDir)\gpg.vs\bin.vs\libgcrypt\$(PlatformName)\release\static";"$(SolutionDir)\otr.vs\bin.vs\libotr\$(PlatformName)\release\static";"$(SolutionDir)\ekhtml\vc9\$(PlatformName)\release""
- GenerateDebugInformation="false"
+ GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
@@ -227,7 +227,7 @@ OutputFile="$(OutDir)\$(ProjectName)A.dll"
LinkIncremental="1"
AdditionalLibraryDirectories=""$(SolutionDir)\gpg.vs\bin.vs\libgcrypt\$(PlatformName)\release\static";"$(SolutionDir)\otr.vs\bin.vs\libotr\$(PlatformName)\release\static";"$(SolutionDir)\ekhtml\vc9\$(PlatformName)\release""
- GenerateDebugInformation="false"
+ GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
diff --git a/MirOTR/entities.cpp b/MirOTR/entities.cpp index c757b70..892681b 100644 --- a/MirOTR/entities.cpp +++ b/MirOTR/entities.cpp @@ -393,3 +393,35 @@ size_t decode_html_entities_utf8(char *dest, const char *src, size_t len) *to = 0; return (size_t)(to - dest); } + +char * encode_html_entities_utf8(const char *src) { + const char *pos, *start=src; + std::string buf; + if (! (pos = strpbrk(start, "&<>\"\r")) ) return NULL; + while (pos) { + buf.append(start, pos-start); + start = pos+1; + switch (*pos) { + case '"': + buf.append("""); + break; + case '<': + buf.append("<"); + break; + case '>': + buf.append(">"); + break; + case '&': + buf.append("&"); + break; + case '\r': + buf.append("<br>\r"); + break; + } + pos = strpbrk(start, "&<>\"\r"); + } + if (strlen(start)) buf.append(start); + pos = mir_strdup(buf.c_str()); + buf.clear(); + return (char*)pos; +}
\ No newline at end of file diff --git a/MirOTR/entities.h b/MirOTR/entities.h index 2fb84af..bf4c8eb 100644 --- a/MirOTR/entities.h +++ b/MirOTR/entities.h @@ -19,4 +19,6 @@ extern size_t decode_html_entities_utf8(char *dest, const char *src, size_t len) the function returns the length of the decoded string */ +extern char * encode_html_entities_utf8(const char *src); + #endif diff --git a/MirOTR/otr.cpp b/MirOTR/otr.cpp index 98ac2a3..f8cc502 100644 --- a/MirOTR/otr.cpp +++ b/MirOTR/otr.cpp @@ -319,11 +319,16 @@ extern "C" { }
int max_message_size(void *opdata, ConnContext *context) {
+ const char *proto;
+ if (context && context->protocol)
+ proto = context->protocol;
+ else
+ proto = contact_get_proto(opdata);
// ugly wokaround for ICQ. ICQ protocol reports more than 7k, but in SMP this is too long.
// possibly ICQ doesn't allow single words without spaces to become longer than ~2340?
- if (strcmp("ICQ", context->protocol)==0 || strncmp("ICQ_", context->protocol, 4)==0)
+ if (strcmp("ICQ", proto)==0 || strncmp("ICQ_", proto, 4)==0)
return 2340;
- return CallProtoService(context->protocol, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, (LPARAM)context->app_data);
+ return CallProtoService(proto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, (LPARAM)opdata);
}
const char *account_name(void *opdata, const char *account, const char *protocol) {
diff --git a/MirOTR/svcs_proto.cpp b/MirOTR/svcs_proto.cpp index a679658..3bcb056 100644 --- a/MirOTR/svcs_proto.cpp +++ b/MirOTR/svcs_proto.cpp @@ -1,6 +1,7 @@ #include "stdafx.h"
#include "svcs_proto.h"
#include "striphtml.h"
+#include "entities.h"
//TODO: Social-Millionaire-Dialoge
int SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){
@@ -44,11 +45,21 @@ int SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
+ char *tmpencode = NULL;
+ ConnContext *context = otrl_context_find_miranda(otr_user_state, (void*)ccs->hContact);
+ if (db_byte_get(ccs->hContact, MODULENAME, "HTMLConv", 0) && otr_context_get_trust(context) >= TRUST_UNVERIFIED) {
+ char *tmpencode = encode_html_entities_utf8(oldmessage_utf);
+ if (tmpencode != NULL) {
+ if (!(ccs->wParam & PREF_UTF)) mir_free(oldmessage_utf);
+ oldmessage_utf = tmpencode;
+ }
+ }
+
char *username = contact_get_id(ccs->hContact); err = otrl_message_sending(otr_user_state, &ops, (void*)ccs->hContact, proto, proto, username, oldmessage_utf, NULL, &newmessage, add_appdata, (void*)ccs->hContact); - if (!(ccs->wParam & PREF_UTF)) mir_free(oldmessage_utf); + if (tmpencode!= NULL || !(ccs->wParam & PREF_UTF)) mir_free(oldmessage_utf); oldmessage_utf = NULL; mir_free(username); @@ -67,8 +78,6 @@ int SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ } else if (newmessage) { /* Fragment the message if necessary, and send all but the last * fragment over the network. We will send the last segment later */ - ConnContext *context = otrl_context_find_miranda(otr_user_state, - (void*)ccs->hContact); // oldmessage_utf is not used anymore, so use it as buffer err = otrl_message_fragment_and_send(&ops, (void*)ccs->hContact, context, @@ -319,7 +328,7 @@ int SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ bool is_miralloc = false; if (context) { TrustLevel level = otr_context_get_trust(context); - if (options.prefix_messages && (level == TRUST_PRIVATE || level == TRUST_UNVERIFIED)) { + if (level >= TRUST_UNVERIFIED) { char* premsg; if (db_byte_get(ccs->hContact, MODULENAME, "HTMLConv", 0)) { premsg = striphtml(newmessage); @@ -328,15 +337,16 @@ int SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ is_miralloc = true; } - - DWORD len = (strlen(options.prefix)+strlen(newmessage)+1)*sizeof(char); - premsg = (char*)mir_alloc( len ); - memset(premsg, 0, len); - strcpy(premsg, options.prefix); - strcat(premsg, newmessage); - (is_miralloc) ? mir_free(newmessage) : otrl_message_free(newmessage); - newmessage = premsg; - is_miralloc = true; + if (options.prefix_messages) { + DWORD len = (strlen(options.prefix)+strlen(newmessage)+1)*sizeof(char); + premsg = (char*)mir_alloc( len ); + memset(premsg, 0, len); + strcpy(premsg, options.prefix); + strcat(premsg, newmessage); + (is_miralloc) ? mir_free(newmessage) : otrl_message_free(newmessage); + newmessage = premsg; + is_miralloc = true; + } } } pre->szMessage = newmessage; diff --git a/MirOTR/version.h b/MirOTR/version.h index 7a8b1ec..ac4590c 100644 --- a/MirOTR/version.h +++ b/MirOTR/version.h @@ -4,11 +4,11 @@ /* VERSION DEFINITIONS */
#define VER_MAJOR 0
#define VER_MINOR 10
-#define VER_RELEASE 1
-#define VER_BUILD 2
+#define VER_RELEASE 2
+#define VER_BUILD 3
#define __STRINGIZE(x) #x
-#define VER_STRING "0.10.1.2"
+#define VER_STRING "0.10.2.3"
#ifdef _UNICODE #define SHORT_NAME_STRING "Miranda OTR"
@@ -30,7 +30,7 @@ my $rootdir = ''; my %hash = ();
my $clines = 0;
-my $version = '0.8';
+my $version = '0.10.2.3';
my $time = localtime();
if (@ARGV && $ARGV[0] eq "version") {
|