BIND 10 trac1626, updated. 318ecd4e65de22d957ed55f571e868ceb3152f97 [1626] check string termination and whitespace fix

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Apr 2 08:51:16 UTC 2012


The branch, trac1626 has been updated
       via  318ecd4e65de22d957ed55f571e868ceb3152f97 (commit)
      from  9a56eb7ebbefcaa29ea623bbf8d7102b6970ff70 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 318ecd4e65de22d957ed55f571e868ceb3152f97
Author: Jelte Jansen <jelte at isc.org>
Date:   Mon Apr 2 10:50:26 2012 +0200

    [1626] check string termination and whitespace fix
    
    whitespace 'outside' of elements is skipped, now including \r and \b

-----------------------------------------------------------------------

Summary of changes:
 src/lib/cc/data.cc                 |    9 ++++++---
 src/lib/cc/tests/data_unittests.cc |    6 +++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc
index e0bed90..018b4ab 100644
--- a/src/lib/cc/data.cc
+++ b/src/lib/cc/data.cc
@@ -354,6 +354,9 @@ str_from_stringstream(std::istream &in, const std::string& file, const int line,
         c = in.get();
         ++pos;
     }
+    if (c == EOF) {
+        throwJSONError("Unterminated string", file, line, pos);
+    }
     return (ss.str());
 }
 
@@ -458,7 +461,7 @@ from_stringstream_list(std::istream &in, const std::string& file, int& line,
     ElementPtr list = Element::createList();
     ConstElementPtr cur_list_element;
 
-    skip_chars(in, " \t\n", line, pos);
+    skip_chars(in, " \t\n\r\b", line, pos);
     while (c != EOF && c != ']') {
         if (in.peek() != ']') {
             cur_list_element = Element::fromJSON(in, file, line, pos);
@@ -476,7 +479,7 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line,
                       int& pos)
 {
     ElementPtr map = Element::createMap();
-    skip_chars(in, " \t\n", line, pos);
+    skip_chars(in, " \t\n\r\b", line, pos);
     char c = in.peek();
     if (c == EOF) {
         throwJSONError(std::string("Unterminated map, <string> or } expected"), file, line, pos);
@@ -574,7 +577,7 @@ Element::fromJSON(std::istream &in, const std::string& file, int& line,
     char c = 0;
     ElementPtr element;
     bool el_read = false;
-    skip_chars(in, " \n\t", line, pos);
+    skip_chars(in, " \n\t\r\b", line, pos);
     while (c != EOF && !el_read) {
         c = in.get();
         pos++;
diff --git a/src/lib/cc/tests/data_unittests.cc b/src/lib/cc/tests/data_unittests.cc
index dbd860f..c732026 100644
--- a/src/lib/cc/tests/data_unittests.cc
+++ b/src/lib/cc/tests/data_unittests.cc
@@ -338,7 +338,11 @@ TEST(Element, escape) {
     // Bad string
     EXPECT_THROW(Element::fromJSON("hello\"foobar\""), JSONError);
     // A whitespace test
-    EXPECT_NO_THROW(Element::fromJSON("  \n  \r \t  \n \n    \t"));
+    EXPECT_NO_THROW(Element::fromJSON("\"  \n  \r \t  \n \n    \t\""));
+    // Whitespace outside of json element
+    EXPECT_NO_THROW(Element::fromJSON("  \n \t \r \b \"\" \n \t \r \b"));
+    EXPECT_NO_THROW(Element::fromJSON("{  \n  \r \t  \b  }"));
+    EXPECT_NO_THROW(Element::fromJSON("[  \n  \r \t  \b  ]"));
 }
 
 TEST(Element, ListElement) {



More information about the bind10-changes mailing list