[Pkg-privacy-commits] [irssi-plugin-otr] 02/18: Detect the libotr-emitted HTML-formatted init string and replace it with a description customized for IRC and irssi-otr.
Antoine Beaupré
anarcat at moszumanska.debian.org
Tue Mar 29 14:20:54 UTC 2016
This is an automated email from the git hooks/post-receive script.
anarcat pushed a commit to branch debian
in repository irssi-plugin-otr.
commit 197f89f2606d6de2471665b421ce527bccf8a04e
Author: Lasse Karkkainen <tronic+ndrm at trn.iki.fi>
Date: Thu May 29 09:49:04 2014 +0300
Detect the libotr-emitted HTML-formatted init string and replace it with a
description customized for IRC and irssi-otr.
---
src/otr.c | 4 ++--
src/otr.h | 4 ++++
src/utils.c | 11 ++++++++++-
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/otr.c b/src/otr.c
index af3f468..f0562f5 100644
--- a/src/otr.c
+++ b/src/otr.c
@@ -363,8 +363,8 @@ int otr_send(SERVER_REC *irssi, const char *msg, const char *to, char **otr_msg)
IRSSI_NOTICE(irssi, to, "Send failed.");
goto error;
}
-
- /* Remove newlines. */
+
+ /* Modify some libotr messages (OTR init in particular) to work better with IRC. */
if (otr_msg) utils_escape_message(*otr_msg);
IRSSI_DEBUG("Message sent...");
diff --git a/src/otr.h b/src/otr.h
index 828c541..de62aa6 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -54,6 +54,10 @@
#define OTR_MSG_BEGIN_TAG "?OTR:"
#define OTR_MSG_END_TAG '.'
+#define OTR_MSG_HELP " This is a request for an Off-the-Record private conversation. "\
+ "However, you do not have a plugin to support that. If you are using Irssi, "\
+ "please install irssi-otr (irssi-plugin-otr).";
+
/* IRC /me command marker and len. */
#define OTR_IRC_MARKER_ME "/me "
#define OTR_IRC_MARKER_ME_LEN sizeof(OTR_IRC_MARKER_ME) - 1
diff --git a/src/utils.c b/src/utils.c
index e3470bf..d6b3af8 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -74,10 +74,19 @@ char *utils_trim_string(char *s)
}
/*
- * Convert invalid characters (newlines from libotr) into spaces
+ * Convert invalid characters (newlines from libotr) into spaces.
+ * Also change the init help string because IRC does not support HTML.
*/
char *utils_escape_message(char *s) {
+ char const* helpmsg = OTR_MSG_HELP;
+ char* p;
size_t i;
+ if (strncmp(s, "?OTR", 4) == 0 && strstr(s, "</b> has requested an <a href")) {
+ i = strcspn(s, "\n");
+ if (i + strlen(helpmsg) <= strlen(s)) {
+ strcpy(s + i, helpmsg);
+ }
+ }
for (i = 0; s[i]; ++i) {
if (s[i] == '\n' || s[i] == '\r') s[i] = ' ';
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git
More information about the Pkg-privacy-commits
mailing list