]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/ContentId.pm
run update-copyrights from gnulib for 2019
[public-inbox.git] / lib / PublicInbox / ContentId.pm
index b1d27eb8e48a8e835c0d088f77e84f3a7e38dd88..9d9be4179b988ad518d19d7a32eff24b937cccca 100644 (file)
@@ -1,6 +1,11 @@
-# Copyright (C) 2018 all contributors <meta@public-inbox.org>
+# Copyright (C) 2018-2019 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
+# Unstable internal API.
+# Used for on-the-fly duplicate detection in V2 inboxes.
+# This is not stored in any database anywhere and may change
+# as changes in duplicate detection are needed.
+# See L<public-inbox-v2-format(5)> manpage for more details.
 package PublicInbox::ContentId;
 use strict;
 use warnings;
@@ -75,14 +80,7 @@ sub content_digest ($) {
                }
                $dig->add("b\0");
                my $ct = $part->content_type || 'text/plain';
-               my $s = eval { $part->body_str };
-               if ($@ && $ct =~ m!\btext/plain\b!i) {
-                       # Try to assume UTF-8 because Alpine
-                       # seems to do wacky things and set
-                       # charset=X-UNKNOWN
-                       $part->charset_set('UTF-8');
-                       $s = eval { $part->body_str };
-               }
+               my ($s, undef) = msg_part_text($part, $ct);
                if (defined $s) {
                        $s =~ s/\r\n/\n/gs;
                        $s =~ s/\s*\z//s;