libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [3/4] libcloud git commit: add support for escaping quotes
Date Sun, 20 Aug 2017 23:32:09 GMT
add support for escaping quotes


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a7da273d
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a7da273d
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a7da273d

Branch: refs/heads/trunk
Commit: a7da273d6f91471d25c2ab524a92a88a052c39f9
Parents: 8041ca2
Author: Anthony Shaw <anthonyshaw@apache.org>
Authored: Mon Aug 21 09:09:25 2017 +1000
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Mon Aug 21 09:09:25 2017 +1000

----------------------------------------------------------------------
 libcloud/dns/drivers/route53.py   |  2 +-
 libcloud/test/dns/test_route53.py | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a7da273d/libcloud/dns/drivers/route53.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/route53.py b/libcloud/dns/drivers/route53.py
index 6632cd3..3b73379 100644
--- a/libcloud/dns/drivers/route53.py
+++ b/libcloud/dns/drivers/route53.py
@@ -561,4 +561,4 @@ class Route53DNSDriver(DNSDriver):
     def _quote_data(self, data):
         if data[0] == '"' and data[-1] == '"':
             return data
-        return '"{0}"'.format(data)
+        return '"{0}"'.format(data.replace('"', '\"'))

http://git-wip-us.apache.org/repos/asf/libcloud/blob/a7da273d/libcloud/test/dns/test_route53.py
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/test_route53.py b/libcloud/test/dns/test_route53.py
index 315ea23..9658c32 100644
--- a/libcloud/test/dns/test_route53.py
+++ b/libcloud/test/dns/test_route53.py
@@ -228,6 +228,21 @@ class Route53Tests(unittest.TestCase):
         self.assertEqual(record.type, RecordType.SPF)
         self.assertEqual(record.data, '"test"')
 
+    def test_create_TXT_record_escaped(self):
+        """
+        Check that TXT record with quotes inside are escaped correctly
+        """
+        zone = self.driver.list_zones()[0]
+        record = self.driver.create_record(
+            name='', zone=zone,
+            type=RecordType.TXT, data='test "with"'
+        )
+        self.assertEqual(record.id, 'TXT:')
+        self.assertEqual(record.name, '')
+        self.assertEqual(record.zone, zone)
+        self.assertEqual(record.type, RecordType.TXT)
+        self.assertEqual(record.data, '"test \"with\""')
+
     def test_create_multi_value_record(self):
         zone = self.driver.list_zones()[0]
         records = self.driver.ex_create_multi_value_record(


Mime
View raw message