+2006-03-25 [colin] 2.0.0cvs169
+
+ * src/matcher.c
+ Fix search in QP-encoded bodies
+ Fix utf-8 searches in bodies encoded in the
+ locale's encoding
+ * src/common/quoted-printable.c
+ * src/common/quoted-printable.h
+ Add a decode function that doesn't overwrite
+ the original pointer
+
+
2006-03-24 [colin] 2.0.0cvs168
* src/action.c
( cvs diff -u -r 1.395.2.185 -r 1.395.2.186 src/summaryview.c; cvs diff -u -r 1.5.2.17 -r 1.5.2.18 src/gtk/description_window.c; ) > 2.0.0cvs166.patchset
( cvs diff -u -r 1.9.2.12 -r 1.9.2.13 src/common/ssl.c; ) > 2.0.0cvs167.patchset
( cvs diff -u -r 1.12.2.32 -r 1.12.2.33 src/action.c; cvs diff -u -r 1.1.2.18 -r 1.1.2.19 src/prefs_msg_colors.c; cvs diff -u -r 1.395.2.186 -r 1.395.2.187 src/summaryview.c; cvs diff -u -r 1.68.2.20 -r 1.68.2.21 src/summaryview.h; cvs diff -u -r 1.23.2.26 -r 1.23.2.27 src/plugins/spamassassin/spamassassin_gtk.c; ) > 2.0.0cvs168.patchset
+( cvs diff -u -r 1.75.2.17 -r 1.75.2.18 src/matcher.c; cvs diff -u -r 1.3.2.5 -r 1.3.2.6 src/common/quoted-printable.c; cvs diff -u -r 1.3.2.2 -r 1.3.2.3 src/common/quoted-printable.h; ) > 2.0.0cvs169.patchset
return outp - str;
}
+gint qp_decode_const(gchar *out, gint avail, const gchar *str)
+{
+ gchar *inp = str, *outp = out;
+
+ while (*inp != '\0' && avail > 0) {
+ if (*inp == '=') {
+ if (inp[1] && inp[2] &&
+ get_hex_value((guchar *)outp, inp[1], inp[2])
+ == TRUE) {
+ inp += 3;
+ } else if (inp[1] == '\0' || g_ascii_isspace(inp[1])) {
+ /* soft line break */
+ break;
+ } else {
+ /* broken QP string */
+ *outp = *inp++;
+ }
+ } else {
+ *outp = *inp++;
+ }
+ outp++;
+ avail--;
+ }
+
+ *outp = '\0';
+
+ return outp - out;
+}
+
gint qp_decode_q_encoding(guchar *out, const gchar *in, gint inlen)
{
const gchar *inp = in;
#include "matcher_parser.h"
#include "prefs_gtk.h"
#include "addr_compl.h"
+#include "codeconv.h"
+#include "quoted-printable.h"
#include <ctype.h>
/*!
}
}
+static gboolean matcherprop_string_decode_match(MatcherProp *prop, const gchar *str)
+{
+ gchar *utf = NULL;
+ gchar tmp[BUFFSIZE];
+ gboolean res = FALSE;
+
+ if (str == NULL)
+ return FALSE;
+
+ /* we try to decode QP first, because it's faster than base64 */
+ qp_decode_const(tmp, BUFFSIZE-1, str);
+ if (!g_utf8_validate(tmp, -1, NULL)) {
+ utf = conv_codeset_strdup
+ (tmp, conv_get_locale_charset_str_no_utf8(),
+ CS_INTERNAL);
+ res = matcherprop_string_match(prop, utf);
+ g_free(utf);
+ } else {
+ res = matcherprop_string_match(prop, tmp);
+ }
+
+ /* FIXME base64 decoding is too slow, especially since text can
+ * easily be handled as base64. Don't even try now. */
+
+ return res;
+}
+
/*!
*\brief Execute a command defined in the matcher structure
*
}
break;
case MATCHCRITERIA_HEADERS_PART:
- case MATCHCRITERIA_MESSAGE:
return matcherprop_string_match(matcher, buf);
+ case MATCHCRITERIA_MESSAGE:
+ return matcherprop_string_decode_match(matcher, buf);
case MATCHCRITERIA_NOT_MESSAGE:
+ return !matcherprop_string_decode_match(matcher, buf);
case MATCHCRITERIA_NOT_HEADERS_PART:
return !matcherprop_string_match(matcher, buf);
}
switch (matcher->criteria) {
case MATCHCRITERIA_BODY_PART:
case MATCHCRITERIA_MESSAGE:
- return matcherprop_string_match(matcher, line);
+ return matcherprop_string_decode_match(matcher, line);
case MATCHCRITERIA_NOT_BODY_PART:
case MATCHCRITERIA_NOT_MESSAGE:
- return !matcherprop_string_match(matcher, line);
+ return !matcherprop_string_decode_match(matcher, line);
}
return FALSE;
}