BIND 10 trac2383, updated. 81cf2b7ac4c5ee295c0d654c4ce24911dd23c2c4 [2383] Clarify @ in names

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Nov 1 13:41:35 UTC 2012


The branch, trac2383 has been updated
       via  81cf2b7ac4c5ee295c0d654c4ce24911dd23c2c4 (commit)
      from  cfcad4db4f9da2525f7c9cddcdd52660f60e4afa (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 81cf2b7ac4c5ee295c0d654c4ce24911dd23c2c4
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Thu Nov 1 14:36:56 2012 +0100

    [2383] Clarify @ in names
    
    If it is alone, it means the origin (or root, if the absolute-name
    constructor is used). If it is not alone, it is taken verbatim, without
    any special meaning.
    
    Add some tests to verify this.
    
    Remove unused enum value. It was a relict from non-exact port of bind9
    code.

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

Summary of changes:
 src/lib/dns/name.cc                |    8 ++------
 src/lib/dns/tests/name_unittest.cc |   25 ++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 7 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/name.cc b/src/lib/dns/name.cc
index 11d5d12..079033a 100644
--- a/src/lib/dns/name.cc
+++ b/src/lib/dns/name.cc
@@ -123,11 +123,7 @@ typedef enum {
     ft_ordinary,                // parsing an ordinary label
     ft_initialescape,           // just found '\'
     ft_escape,                  // begin of handling a '\'-escaped sequence
-    ft_escdecimal,              // parsing a '\DDD' octet.
-
-    // Unused at this moment.  We'll revisit this when we support master file
-    // parser where @ is used to mean an origin name.
-    ft_at
+    ft_escdecimal               // parsing a '\DDD' octet.
 } ft_state;
 
 // The parser of name from a string. It is a template, because
@@ -283,7 +279,7 @@ stringParse(Iterator s, Iterator send, bool downcase, Offsets& offsets,
                       string(orig_s, send));
         }
         assert(s == send);
-        if (state != ft_ordinary && state != ft_at) {
+        if (state != ft_ordinary) {
             isc_throw(IncompleteName,
                       "incomplete textual name in " <<
                       (empty ? "<empty>" : string(orig_s, send)));
diff --git a/src/lib/dns/tests/name_unittest.cc b/src/lib/dns/tests/name_unittest.cc
index 11ac929..10d1e55 100644
--- a/src/lib/dns/tests/name_unittest.cc
+++ b/src/lib/dns/tests/name_unittest.cc
@@ -295,6 +295,30 @@ TEST_F(NameTest, combinedTooLong) {
                          &Name::ROOT_NAME()));
 }
 
+// Test the handling of @ in the name. If it is alone, it is the origin (when
+// it exists) or the root. If it is somewhere else, it has no special meaning.
+TEST_F(NameTest, atSign) {
+    // If it is alone, it is the origin
+    EXPECT_EQ(origin_name, Name("@", 1, &origin_name));
+    EXPECT_THROW(Name("@", 1, NULL), MissingNameOrigin);
+    EXPECT_EQ(Name::ROOT_NAME(), Name("@"));
+
+    // It is not alone. It is taken verbatim. We check the name converted
+    // back to the textual form, since checking it agains other name object
+    // may be wrong -- if we create it wrong the same way as the tested
+    // object.
+    EXPECT_EQ("\\@.", Name("@.").toText());
+    EXPECT_EQ("\\@.", Name("@.", 2, NULL).toText());
+    EXPECT_EQ("\\@something.", Name("@something").toText());
+    EXPECT_EQ("something\\@.", Name("something@").toText());
+    EXPECT_EQ("\\@x.example.com.", Name("@x", 2, &origin_name).toText());
+    EXPECT_EQ("x\\@.example.com.", Name("x@", 2, &origin_name).toText());
+
+    // An escaped at-sign isn't active
+    EXPECT_EQ("\\@.", Name("\\@").toText());
+    EXPECT_EQ("\\@.example.com.", Name("\\@", 2, &origin_name).toText());
+}
+
 TEST_F(NameTest, fromWire) {
     //
     // test cases derived from BIND9 tests.
@@ -593,7 +617,6 @@ TEST_F(NameTest, downcase) {
     // confirm the calling object is actually modified
     example_name_upper.downcase();
     compareInWireFormat(example_name_upper, example_name);
-    
 }
 
 TEST_F(NameTest, at) {



More information about the bind10-changes mailing list