GList *cur_offset;
struct process_exception *cur_ex = NULL;
gunichar uc;
+ GString *debug;
cur_offset = part->urls_offset;
if (cur_offset != NULL) {
}
}
+ debug = g_string_sized_new (real_len);
new->block_size = fuzzy_blocksize (real_len);
new2->block_size = new->block_size * 2;
uc = g_utf8_get_char (c);
if (g_unichar_isalnum (uc)) {
fuzzy_update2 (new, new2, uc);
+ g_string_append_unichar (debug, uc);
}
c = g_utf8_next_char (c);
}
else {
if (!g_ascii_isspace (*c) && !g_ascii_ispunct (*c)) {
fuzzy_update2 (new, new2, *c);
+ g_string_append_c (debug, *c);
}
c++;
}
}
}
+ msg_info ("make hash of string: %v", debug);
/* Check whether we have more bytes in a rolling window */
if (new->rh != 0) {
new->hash_pipe[new->hi] = b64[new->h % 64];
LUA_FUNCTION_DEF (textpart, is_html);
LUA_FUNCTION_DEF (textpart, get_fuzzy);
LUA_FUNCTION_DEF (textpart, get_language);
+LUA_FUNCTION_DEF (textpart, compare_distance);
static const struct luaL_reg textpartlib_m[] = {
LUA_INTERFACE_DEF (textpart, get_content),
LUA_INTERFACE_DEF (textpart, is_html),
LUA_INTERFACE_DEF (textpart, get_fuzzy),
LUA_INTERFACE_DEF (textpart, get_language),
+ LUA_INTERFACE_DEF (textpart, compare_distance),
{"__tostring", lua_class_tostring},
{NULL, NULL}
};
return 1;
}
+static gint
+lua_textpart_compare_distance (lua_State * L)
+{
+ struct mime_text_part *part = lua_check_textpart (L), *other;
+ void *ud = luaL_checkudata (L, 2, "rspamd{textpart}");
+ gint diff = -1;
+ GMimeObject *parent;
+ const GMimeContentType *ct;
+
+ luaL_argcheck (L, ud != NULL, 2, "'textpart' expected");
+ other = *((struct mime_text_part **)ud);
+
+ if (part->parent && part->parent == other->parent) {
+ parent = part->parent;
+ ct = g_mime_object_get_content_type (parent);
+#ifndef GMIME24
+ if (ct == NULL || ! g_mime_content_type_is_type (ct, "multipart", "alternative")) {
+#else
+ if (ct == NULL || ! g_mime_content_type_is_type ((GMimeContentType *)ct, "multipart", "alternative")) {
+#endif
+ diff = -1;
+
+ }
+ else {
+ if (!part->is_empty && !other->is_empty) {
+ diff = fuzzy_compare_parts (part, other);
+ }
+ else if ((part->is_empty && !other->is_empty) || (!part->is_empty && other->is_empty)) {
+ /* Empty and non empty parts are different */
+ diff = 0;
+ }
+ }
+ }
+ else {
+ diff = -1;
+ }
+
+
+ lua_pushinteger (L, diff);
+
+ return 1;
+}
+
/* Image functions */
static gint
lua_image_get_width (lua_State *L)