From 4da8961aab39859cc592a0e7e62558f26a95aae2 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Wed, 15 Jan 2020 22:25:19 -0500 Subject: [PATCH] Split the lines --- source/whitelist.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/whitelist.cpp b/source/whitelist.cpp index 510d2f3..108eaa9 100644 --- a/source/whitelist.cpp +++ b/source/whitelist.cpp @@ -26,10 +26,16 @@ int parseWhitelist() std::stringstream filereader; filereader << input.rdbuf(); std::string filedata = filereader.str(); - std::regex line_parser("[ \t]*([\\w\\.-]+)\\:(\\d+)(?:(?:[ \t]*\r?\n)+|[ \t]*$)"); - for (std::regex_iterator match = std::regex_iterator(filedata.begin(), filedata.end(), line_parser), end = std::regex_iterator(); match != end; ++match) + std::regex line_parser("(?:(?!\r?\n).)+"); + std::regex entry_parser("^[ \\t]*([\\w\\.-]+)\\:(\\d+)[ \\t]*$"); + for (std::sregex_iterator line = std::sregex_iterator(filedata.begin(), filedata.end(), line_parser), end = std::sregex_iterator(); line != end; ++line) { - whitelist[match->operator[](1).str()].insert(match->operator[](2).str()); + const std::string& linestr = line->operator[](0); + std::smatch match; + if(std::regex_match(linestr, match, entry_parser)) + { + whitelist[match[1].str()].insert(match[2].str()); + } } if (whitelist.empty()) {