diff options
author | Kiall Mac Innes <kiall@hp.com> | 2013-08-21 13:38:01 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-08-21 13:38:01 +0000 |
commit | fcf1e10fcf43b4c31ca352354fe8191431f6fce2 (patch) | |
tree | 9df26ee871dad8db49a27a1bc9c4339b6e6e91fc | |
parent | 0f781dfdb673dde771647313346e0f5406dbbf9d (diff) | |
download | designate-fcf1e10fcf43b4c31ca352354fe8191431f6fce2.tar.gz |
Revert "PowerDNS - Ensure SPF records are quoted correctly"
This change was totally wrong in practice.
This reverts commit 0f781dfdb673dde771647313346e0f5406dbbf9d
-rw-r--r-- | designate/backend/impl_powerdns/__init__.py | 4 | ||||
-rw-r--r-- | designate/tests/test_utils.py | 28 | ||||
-rw-r--r-- | designate/utils.py | 38 |
3 files changed, 1 insertions, 69 deletions
diff --git a/designate/backend/impl_powerdns/__init__.py b/designate/backend/impl_powerdns/__init__.py index c8f9e8b5..4b04b26a 100644 --- a/designate/backend/impl_powerdns/__init__.py +++ b/designate/backend/impl_powerdns/__init__.py @@ -22,7 +22,6 @@ from sqlalchemy.orm import exc as sqlalchemy_exceptions from oslo.config import cfg from designate.openstack.common import log as logging from designate import exceptions -from designate import utils from designate.backend import base from designate.backend.impl_powerdns import models from designate.sqlalchemy.session import get_session @@ -295,9 +294,6 @@ class PowerDNSBackend(base.Backend): if type in ('CNAME', 'MX', 'SRV', 'NS', 'PTR'): return content.rstrip('.') - if type in ('TXT', 'SPF'): - return utils.quote_string(content) - return content def _build_soa_content(self, domain, servers): diff --git a/designate/tests/test_utils.py b/designate/tests/test_utils.py index 2ddf5026..1efbf244 100644 --- a/designate/tests/test_utils.py +++ b/designate/tests/test_utils.py @@ -64,7 +64,7 @@ class TestUtils(TestCase): self.assertEqual('Hello World', result) - def test_render_template_to_file(self): + def render_template_to_file(self): output_path = tempfile.mktemp() template = Template("Hello {{name}}") @@ -79,29 +79,3 @@ class TestUtils(TestCase): self.assertEqual('Hello World', fh.read()) finally: os.unlink(output_path) - - def test_quote_string(self): - self.assertEqual('""', utils.quote_string('')) - self.assertEqual('""', utils.quote_string('"')) - self.assertEqual('""', utils.quote_string('""')) - self.assertEqual('"hello"', utils.quote_string('hello')) - self.assertEqual('"hello1" "hello2"', - utils.quote_string('hello1 hello2')) - self.assertEqual('"hello1" "hello2"', - utils.quote_string('"hello1" hello2')) - self.assertEqual('"hello1" "hello2"', - utils.quote_string('hello1 "hello2"')) - self.assertEqual('"hello1" "hello2" "hello3"', - utils.quote_string('"hello1" hello2 "hello3"')) - self.assertEqual('"properly quoted string"', - utils.quote_string('"properly quoted string"')) - self.assertEqual('"not" "properly" "quoted" "string"', - utils.quote_string('not properly quoted string')) - self.assertEqual('"properly quoted \\" string"', - utils.quote_string('"properly quoted \\" string"')) - self.assertEqual('"single" "quote" "at" "the" "end\\""', - utils.quote_string('single quote at the end"')) - self.assertEqual('"single" "quote" "in\\"" "the" "middle"', - utils.quote_string('single quote in\\" the middle')) - self.assertEqual('"single quote at the start"', - utils.quote_string('"single quote at the start')) diff --git a/designate/utils.py b/designate/utils.py index c1122d40..794461d9 100644 --- a/designate/utils.py +++ b/designate/utils.py @@ -183,41 +183,3 @@ def increment_serial(serial=0): new_serial = serial + 1 return new_serial - - -def quote_string(string): - inparts = string.split(' ') - outparts = [] - tmp = None - - for part in inparts: - if part == '': - continue - elif part[0] == '"' and part[-1:] == '"' and part[-2:] != '\\"': - # Handle Quoted Words - outparts.append(part.strip('"')) - elif part[0] == '"': - # Handle Start of Quoted Sentance - tmp = part[1:] - elif tmp is not None and part[-1:] == '"' and part[-2:] != '\\"': - # Handle End of Quoted Sentance - tmp += " " + part.strip('"') - outparts.append(tmp) - tmp = None - elif tmp is not None: - # Handle Middle of Quoted Sentance - tmp += " " + part - else: - # Handle Standalone words - outparts.append(part) - - if tmp is not None: - # Handle unclosed quoted strings - outparts.append(tmp) - - # This looks odd, but both calls are necessary to ensure the end results - # is always consistent. - outparts = [o.replace('\\"', '"') for o in outparts] - outparts = [o.replace('"', '\\"') for o in outparts] - - return '"' + '" "'.join(outparts) + '"' |