Changeset 34 for trunk


Ignore:
Timestamp:
02/11/13 16:27:42 (12 years ago)
Author:
tmorgan
Message:

added limited support for base64 blobs with inline newlines

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bletchley/blobtools.py

    r28 r34  
    3232class DataEncoding(object):
    3333    charset = frozenset('')
     34    extraneous_chars = ''
    3435    dialect = None
    3536    name = None
     
    104105            self.pad = '='
    105106       
     107        if 'newline' in dialect:
     108            self.extraneous_chars = '\r\n'
     109
    106110        self.charset = frozenset('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    107111                                 +'abcdefghijklmnopqrstuvwxyz0123456789'
    108                                  +self.c62+self.c63+self.pad)
     112                                 +self.c62+self.c63+self.pad+self.extraneous_chars)
    109113
    110114    def _guessPadLength(self, nopad_len):
     
    115119
    116120    def extraTests(self, blob):
     121        for c in self.extraneous_chars:
     122            blob = blob.replace(c, '')
     123
    117124        nopad = blob.rstrip(self.pad)
    118125        padlen_guess = self._guessPadLength(len(nopad))
     
    129136
    130137    def decode(self, blob):
     138        for c in self.extraneous_chars:
     139            blob = blob.replace(c, '')
     140
    131141        if self.dialect.endswith('nopad'):
    132142            if self.pad in blob:
     
    292302    (base64Encoding, 'rfc3548', 200),
    293303    (base64Encoding, 'rfc3548-nopad', 201),
     304    (base64Encoding, 'rfc3548-newline', 202),
    294305    (base64Encoding, 'filename', 210),
    295306    (base64Encoding, 'filename-nopad', 211),
Note: See TracChangeset for help on using the changeset viewer.