name: Make sure empty name component (...) is not skipped during URI decoding

Change-Id: I85f96711b335573156c2c00722847d187ecf194c
Refs: #2725
diff --git a/src/name.cpp b/src/name.cpp
index c388064..b180ba6 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -162,11 +162,7 @@
     if (iComponentEnd == std::string::npos)
       iComponentEnd = uri.size();
 
-    Component component = Component::fromEscapedString(&uri[0], iComponentStart, iComponentEnd);
-    // Ignore illegal components.  This also gets rid of a trailing '/'.
-    if (!component.empty())
-      append(Component(component));
-
+    append(Component::fromEscapedString(&uri[0], iComponentStart, iComponentEnd));
     iComponentStart = iComponentEnd + 1;
   }
 }
diff --git a/tests/unit-tests/name.t.cpp b/tests/unit-tests/name.t.cpp
index 6271c7a..7576b61 100644
--- a/tests/unit-tests/name.t.cpp
+++ b/tests/unit-tests/name.t.cpp
@@ -165,6 +165,7 @@
 
   Name name2;
   BOOST_REQUIRE_NO_THROW(name2 = std::move(Name(nameUri)));
+  BOOST_CHECK_EQUAL(name2.toUri(), nameUri);
   Block name2Encoded = name2.wireEncode();
   BOOST_CHECK(name2Encoded == nameBlock);
 }
@@ -493,6 +494,15 @@
   }
 }
 
+BOOST_AUTO_TEST_CASE(NameWithSpaces)
+{
+  Name name("/ hello\t/\tworld \r\n");
+
+  BOOST_CHECK_EQUAL("/hello/world", name);
+  BOOST_CHECK_THROW(Name("/hello//world"), name::Component::Error);
+}
+
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace tests