@@ -65,26 +65,26 @@ def evaluate(self, message: Message, state: EvaluationState) -> Optional[bool]:
6565 # if there are no headers, we match ^\n, which is guaranteed to be there
6666 (_ , bodystr ) = re .split (r'^\r?\n|\r?\n\r?\n' , message .as_string (False ), 1 )
6767 return self .evaluate_part (bodystr , state )
68- else :
69- for msgpart in message .walk ():
70- if msgpart .is_multipart ():
71- # TODO: If "multipart/*" extract prologue and epilogue and make that searcheable
72- # TODO: If "message/rfc822" extract headers and make that searchable
73- # Insetad we skip multipart objects and descend into its children
74- continue
75- msgtxt = msgpart .get_payload ()
76- for mimetype in self .body_transform :
77- if not mimetype : # empty body_transform matches all
78- if self .evaluate_part (msgtxt , state ):
79- return True
80- match = re .match (r'^([^/]+)(?:/([^/]+))?$' , mimetype )
81- if not match :
82- continue # malformed body_transform is skipped
83- (maintype , subtype ) = match .groups ()
84- if maintype == msgpart .get_content_maintype () and (
85- not subtype or subtype == msgpart .get_content_subtype ()):
86- if self .evaluate_part (msgtxt , state ):
87- return True
68+
69+ for msgpart in message .walk ():
70+ if msgpart .is_multipart ():
71+ # TODO: If "multipart/*" extract prologue and epilogue and make that searcheable
72+ # TODO: If "message/rfc822" extract headers and make that searchable
73+ # Insetad we skip multipart objects and descend into its children
74+ continue
75+ msgtxt = msgpart .get_payload ()
76+ for mimetype in self .body_transform :
77+ if not mimetype : # empty body_transform matches all
78+ if self .evaluate_part (msgtxt , state ):
79+ return True
80+ match = re .match (r'^([^/]+)(?:/([^/]+))?$' , mimetype )
81+ if not match :
82+ continue # malformed body_transform is skipped
83+ (maintype , subtype ) = match .groups ()
84+ if maintype == msgpart .get_content_maintype () and (
85+ not subtype or subtype == msgpart .get_content_subtype ()):
86+ if self .evaluate_part (msgtxt , state ):
87+ return True
8888 return False
8989
9090 def evaluate_part (self , part_str : Text , state : EvaluationState ) -> bool :
0 commit comments