end
for _,part in ipairs(parts) do
if not part:is_multipart() then
- table.insert(out_elts[fname], {
- digest = part:get_digest(),
- file = part:get_filename(),
- type = string.format('%s/%s', part:get_type())
- })
-
+ local text = part:get_text()
+
+ if text then
+ local digest,shingles = text:get_fuzzy_hashes(task:get_mempool())
+ table.insert(out_elts[fname], {
+ digest = digest,
+ shingles = rspamd_logger.slog('%s', shingles),
+ type = string.format('%s/%s', part:get_type())
+ })
+ else
+ table.insert(out_elts[fname], {
+ digest = part:get_digest(),
+ file = part:get_filename(),
+ type = string.format('%s/%s', part:get_type())
+ })
+ end
end
end
end
/* TODO: add short text support */
/* Calculate direct hash */
+ rspamd_cryptobox_hash_init (&st, key, rspamd_cryptobox_HASHKEYBYTES);
+
for (i = 0; i < part->normalized_words->len; i ++) {
word = &g_array_index (part->normalized_words, rspamd_stat_token_t, i);
rspamd_cryptobox_hash_update (&st, word->begin, word->len);
rspamd_encode_hex_buf (digest, sizeof (digest), hexdigest,
sizeof (hexdigest));
- lua_pushstring (L, hexdigest);
+ lua_pushlstring (L, hexdigest, sizeof (hexdigest) - 1);
sgl = rspamd_shingles_from_text (part->normalized_words, key,
pool, lua_shingles_filter, part, RSPAMD_SHINGLES_MUMHASH);