Python quopri.encodestring() Examples

The following are 30 code examples of quopri.encodestring(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module quopri , or try the search function .
Example #1
Source File: mhtml.py    From chrome-prerender with MIT License 6 votes vote down vote up
def add(self, location: str, content_type: str, payload: str, encoding: str = 'quoted-printable') -> None:
        resource = EmailMessage()
        if content_type == 'text/html':
            resource.add_header('Content-Type', 'text/html', charset='utf-8')
        else:
            resource['Content-Type'] = content_type
        if encoding == 'quoted-printable':
            resource['Content-Transfer-Encoding'] = encoding
            resource.set_payload(quopri.encodestring(payload.encode()))
        elif encoding == 'base64':
            resource['Content-Transfer-Encoding'] = encoding
            resource.set_payload(base64.b64encode(payload))
        elif encoding == 'base64-encoded':  # Already base64 encoded
            resource['Content-Transfer-Encoding'] = 'base64'
            resource.set_payload(payload)
        else:
            raise ValueError('invalid encoding')
        resource['Content-Location'] = location
        self._msg.attach(resource) 
Example #2
Source File: test_quopri.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_embedded_ws(self):
        for p, e in self.ESTRINGS:
            self.assert_(quopri.encodestring(p, quotetabs=True) == e)
            self.assert_(quopri.decodestring(e) == p) 
Example #3
Source File: encoders.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #4
Source File: encoders.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(b' ', b'=20') 
Example #5
Source File: test_quopri.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_encodestring(self):
        for p, e in self.STRINGS:
            self.assertTrue(quopri.encodestring(p) == e) 
Example #6
Source File: test_quopri.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_idempotent_string(self):
        for p, e in self.STRINGS:
            self.assertTrue(quopri.decodestring(quopri.encodestring(e)) == e) 
Example #7
Source File: encoders.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #8
Source File: encoders.py    From android_universal with MIT License 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(b' ', b'=20') 
Example #9
Source File: encoders.py    From unity-python with MIT License 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #10
Source File: encoders.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #11
Source File: encoders.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #12
Source File: encoders.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #13
Source File: plugin_quopri.py    From deen with Apache License 2.0 5 votes vote down vote up
def process(self, data):
        super(DeenPluginQuopri, self).process(data)
        try:
            data = quopri.encodestring(data)
        except Exception as e:
            self.error = e
            self.log.error(self.error)
            self.log.debug(self.error, exc_info=True)
        return data 
Example #14
Source File: encoders.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(b' ', b'=20') 
Example #15
Source File: test_quopri.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_encode_header(self):
        for p, e in self.HSTRINGS:
            self.assert_(quopri.encodestring(p, header=True) == e) 
Example #16
Source File: encoders.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #17
Source File: test_quopri.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_idempotent_string(self):
        for p, e in self.STRINGS:
            self.assert_(quopri.decodestring(quopri.encodestring(e)) == e) 
Example #18
Source File: test_quopri.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_encodestring(self):
        for p, e in self.STRINGS:
            self.assert_(quopri.encodestring(p) == e) 
Example #19
Source File: encoders.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #20
Source File: test_quopri.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_encode_header(self):
        for p, e in self.HSTRINGS:
            self.assertEqual(quopri.encodestring(p, header=True), e) 
Example #21
Source File: test_quopri.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_embedded_ws(self):
        for p, e in self.ESTRINGS:
            self.assertEqual(quopri.encodestring(p, quotetabs=True), e)
            self.assertEqual(quopri.decodestring(e), p) 
Example #22
Source File: test_quopri.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_idempotent_string(self):
        for p, e in self.STRINGS:
            self.assertEqual(quopri.decodestring(quopri.encodestring(e)), e) 
Example #23
Source File: test_quopri.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_encodestring(self):
        for p, e in self.STRINGS:
            self.assertEqual(quopri.encodestring(p), e) 
Example #24
Source File: encoders.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(b' ', b'=20') 
Example #25
Source File: encoders.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #26
Source File: encoders.py    From datafari with Apache License 2.0 5 votes vote down vote up
def _qencode(s):
    enc = _encodestring(s, quotetabs=True)
    # Must encode spaces, which quopri.encodestring() doesn't do
    return enc.replace(' ', '=20') 
Example #27
Source File: test_quopri.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_encode_header(self):
        for p, e in self.HSTRINGS:
            self.assertTrue(quopri.encodestring(p, header=True) == e) 
Example #28
Source File: test_quopri.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_embedded_ws(self):
        for p, e in self.ESTRINGS:
            self.assertTrue(quopri.encodestring(p, quotetabs=True) == e)
            self.assertTrue(quopri.decodestring(e) == p) 
Example #29
Source File: test_quopri.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_idempotent_string(self):
        for p, e in self.STRINGS:
            self.assertTrue(quopri.decodestring(quopri.encodestring(e)) == e) 
Example #30
Source File: test_quopri.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_encodestring(self):
        for p, e in self.STRINGS:
            self.assertTrue(quopri.encodestring(p) == e)