]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5356] Improved decommentJSONFile to handle iPXE URLs
authorFrancis Dupont <fdupont@isc.org>
Thu, 19 Oct 2017 11:16:27 +0000 (13:16 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 19 Oct 2017 11:16:27 +0000 (13:16 +0200)
src/bin/dhcp6/tests/parser_unittest.cc
src/lib/testutils/io_utils.cc
src/lib/testutils/io_utils.h

index fcb20b638eba9798b6d0937315949b12b51ce924..fdc9c85f3865dc0ae16531a17407cde9dfed5bd0 100644 (file)
@@ -251,8 +251,7 @@ TEST(ParserTest, file) {
     configs.push_back("dhcpv4-over-dhcpv6.json");
     configs.push_back("duid.json");
     configs.push_back("hooks.json");
-    // Removed because decommentJSON does not work with URLs
-    // configs.push_back("iPXE.json");
+    configs.push_back("iPXE.json");
     configs.push_back("leases-expiration.json");
     configs.push_back("multiple-options.json");
     configs.push_back("mysql-reservations.json");
index 0081707e97819825ad6ae54b2ef0ab443b60fa73..93558a4d4664c4780f59d0e1e62fe07459522143 100644 (file)
@@ -69,8 +69,11 @@ std::string decommentJSONfile(const std::string& input_file) {
         }
 
         // Second, let's get rid of the // comments
+        // at the beginning or after a control character.
         size_t dblslash_pos = line.find("//");
-        if (dblslash_pos != string::npos) {
+        if ((dblslash_pos != string::npos) &&
+            ((dblslash_pos == 0) ||
+             ((unsigned) line[dblslash_pos - 1] <= 32))) {
             line = line.substr(0, dblslash_pos);
         }
 
index ce4b57ccf29f657edfd707fcf41956b4d8d2da68..58fd01570626f357cb5851f1d005f328954c6629 100644 (file)
@@ -32,7 +32,7 @@ std::string readFile(const std::string& file_path);
 /// token locations should remain unaffected. This is rather naive
 /// implementation, but it's probably sufficient for testing. It won't be able
 /// to pick any trickier cases, like # or // appearing in strings, nested C++
-/// comments etc.
+/// comments etc at the exception of // in URLs.
 ///
 /// @param input_file file to be stripped of comments
 /// @return filename of a new file that has comments stripped from it