~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/model/queue.py

  • Committer: William Grant
  • Date: 2011-05-19 01:50:46 UTC
  • mto: This revision was merged to the branch mainline in revision 13117.
  • Revision ID: william.grant@canonical.com-20110519015046-0iq10xln2c0r3347
Extract _stripPgpSignature into a function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
        return guess_encoding(s)
143
143
 
144
144
 
 
145
def strip_pgp_signature(text):
 
146
    """Strip any PGP signature from the supplied changes lines."""
 
147
    signed_message = signed_message_from_string(text)
 
148
    # For unsigned '.changes' files we'll get a None `signedContent`.
 
149
    if signed_message.signedContent is not None:
 
150
        return signed_message.signedContent
 
151
    else:
 
152
        return text
 
153
 
 
154
 
145
155
class PackageUploadQueue:
146
156
 
147
157
    implements(IPackageUploadQueue)
709
719
        """See `IPackageUpload`."""
710
720
        return self.archive.is_ppa
711
721
 
712
 
    def _stripPgpSignature(self, changes_lines):
713
 
        """Strip any PGP signature from the supplied changes lines."""
714
 
        text = "".join(changes_lines)
715
 
        signed_message = signed_message_from_string(text)
716
 
        # For unsigned '.changes' files we'll get a None `signedContent`.
717
 
        if signed_message.signedContent is not None:
718
 
            return signed_message.signedContent.splitlines(True)
719
 
        else:
720
 
            return changes_lines
721
 
 
722
722
    def _getChangesDict(self, changes_file_object=None, allow_unsigned=None):
723
723
        """Return a dictionary with changes file tags in it."""
724
724
        changes_lines = None
746
746
        # Leaving the PGP signature on a package uploaded
747
747
        # leaves the possibility of someone hijacking the notification
748
748
        # and uploading to any archive as the signer.
749
 
        changes_lines = self._stripPgpSignature(changes_lines)
 
749
        changes_lines = strip_pgp_signature(
 
750
            "".join(changes_lines)).splitlines(True)
750
751
 
751
752
        return changes, changes_lines
752
753