Mail::...:Pieces(3pm)

πŸ’– NAME πŸ’–

Mail::SpamAssassin::Pyzor::Digest::Pieces β€” Pyzor backend logic module ✨ (it's a Perl module, bestie, the (3pm) is just its little name tag)


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: this module is where all the backend logic lives for Mail::SpamAssassin::Pyzor::Digest. it's the behind-the-scenes girlie doing the actual work while everyone else takes the credit, no cap πŸ’…

and like, it literally reimplements the logic that already exists over in pyzor's digest.py module, which you can peek at here: https://github.com/SpamExperts/pyzor/blob/master/pyzor/digest.py 🫢


⭐ FUNCTIONS ⭐

🌸 $strings_ar = digest_payloads( $EMAIL_MIME )

this one is giving ✨understudy energy✨ β€” it imitates the corresponding object method up in digest.py. what you get back is a reference to an array of strings. and each one of those strings can be either a byte string or a character string (like, say, a UTF-8 decoded one). versatile queen 😌

NB: RFC 2822 said what it said β€” message bodies are supposed to use CRLF line breaks, not plain LF, and definitely not plain CR. so bestie, we take any plain CRs hanging out in a quoted-printable message body and convert them into CRLF. iconic of us honestly. but β€” Python does not do this 😭 so the output of our digest_payloads() diverges from the Python original's. it doesn't ultimately make a difference since the line-ending whitespace gets trimmed regardless, but you 100% have to factor it in whenever you compare our implementation's output against the Python output. noted. periodt.

πŸŽ€ normalize( $STRING )

another one that imitates the corresponding object method in digest.py 🫢 heads up though: it modifies $STRING in-place. no copy, no refund, she's changing your variable right there in front of you.

and fr fr, same as with the original implementation: if $STRING contains (decoded) Unicode characters, those characters get parsed accordingly. so check it:

$str = "123\xc2\xa0";   # [ c2 a0 ] == \u00a0, non-breaking space

normalize($str);

the above will leave $str alone (untouched, unbothered, moisturized). but this:

utf8::decode($str);

normalize($str);

... will trim off the last two bytes from $str. the way that one line of utf8::decode changes your whole life 😭


πŸ’œ $yn = should_handle_line( $STRING )

imitates the corresponding object method in digest.py, as always πŸ’… and it returns a boolean. yes/no, true/false, vibe check passed or failed, that's the whole thing.


🧚 $sr = assemble_lines( \@LINES )

this one assembles a string buffer out of @LINES. and that string? that's the buffer of octets that will get hashed to produce the message digest πŸ”₯ so like, don't play with her.

every single member of @LINES is expected to be an octet string, not a character string. keep it bytes only bestie, that's the rule πŸ™ˆ


πŸ‘‘ ($main, $sub, $encoding, $checkval) = parse_content_type( $CONTENT_TYPE )

🌈 @lines = splitlines( $TEXT )

both of these share the same little description, so here it is for the both of them ✨:

imitates "str.splitlines()". (cf. "pydoc str")

returns a plain list in list context πŸŽ€ and returns the number of items to be returned in scalar context. context really is everything, she contains multitudes πŸ’…


πŸ’Œ a lil sign-off πŸ’Œ

that's the whole page bestie!! this one's from perl v5.40.1, dated 2026-07-23, and it's filed under Mail::...:Pieces(3pm) πŸ¦‹ take care of her, she's been out here faithfully reimplementing Python logic since forever. mwah πŸ’–

πŸ“¦ where this page comes from