# HG changeset patch # User Paul Boddie # Date 1389134779 -3600 # Node ID 33492399902b9a1cc2f834f963a9c842db5fdc94 # Parent 3b4e75a573a496069c40cfb1905dc0e6d0708ff4 Fixed handling of incoming signed content in MoinMessageSupport. Added a convenience function for getting the original, unwrapped signed content. diff -r 3b4e75a573a4 -r 33492399902b MoinMessage.py --- a/MoinMessage.py Tue Jan 07 20:08:13 2014 +0100 +++ b/MoinMessage.py Tue Jan 07 23:46:19 2014 +0100 @@ -2,7 +2,7 @@ """ MoinMoin - MoinMessage library - @copyright: 2012, 2013 by Paul Boddie + @copyright: 2012, 2013, 2014 by Paul Boddie @license: GNU GPL (v2 or later), see COPYING.txt for details. """ @@ -279,12 +279,7 @@ # Verify the message. fingerprint, identity = self.verifyMessageText(signature.get_payload(decode=True), content.as_string()) - - # Extract the actual content inside the signed message. - # This reverses the wrapping up of signed content in a - # representation-insensitive container. - - return fingerprint, identity, Parser().parsestr(content.get_payload(decode=True)) + return fingerprint, identity, getOriginalContent(content) def signMessage(self, message, keyid): @@ -294,8 +289,7 @@ # Make a representation-insensitive container for the message. - text = message.as_string() - content = MIMEApplication(text) + content = MIMEApplication(message.as_string()) # Sign the container's representation. @@ -491,6 +485,15 @@ except ValueError: raise MoinMessageMissingPart +def getOriginalContent(content): + + """ + Extract the actual content inside the signed message. This reverses the + wrapping up of signed content in a representation-insensitive container. + """ + + return Parser().parsestr(content.get_payload(decode=True)) + # Communications functions. def timestamp(message): diff -r 3b4e75a573a4 -r 33492399902b MoinMessageSupport.py --- a/MoinMessageSupport.py Tue Jan 07 20:08:13 2014 +0100 +++ b/MoinMessageSupport.py Tue Jan 07 23:46:19 2014 +0100 @@ -2,7 +2,7 @@ """ MoinMoin - MoinMessageSupport library - @copyright: 2012, 2013 by Paul Boddie + @copyright: 2012, 2013, 2014 by Paul Boddie @license: GNU GPL (v2 or later), see COPYING.txt for details. """ @@ -16,7 +16,8 @@ from TokenSupport import getIdentifiers from MoinMessage import GPG, Message, MoinMessageError, \ MoinMessageMissingPart, MoinMessageBadContent, \ - is_signed, is_encrypted, getContentAndSignature + is_signed, is_encrypted, getContentAndSignature, \ + getOriginalContent from email.parser import Parser import time @@ -166,7 +167,7 @@ # Handle the embedded message. content, signature = getContentAndSignature(message) - self.handle_message_content(content) + self.handle_message_content(getOriginalContent(content)) # Reject any unverified message.