mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Trim whitespace for all config lines
FIXES: 2979
This commit is contained in:
@@ -69,6 +69,9 @@ parseIniFile (std::string const& strInput, const bool bTrim)
|
||||
// Parse each line.
|
||||
for (auto& strValue : vLines)
|
||||
{
|
||||
if (bTrim)
|
||||
boost::algorithm::trim (strValue);
|
||||
|
||||
if (strValue.empty () || strValue[0] == '#')
|
||||
{
|
||||
// Blank line or comment, do nothing.
|
||||
@@ -82,9 +85,6 @@ parseIniFile (std::string const& strInput, const bool bTrim)
|
||||
else
|
||||
{
|
||||
// Another line for Section.
|
||||
if (bTrim)
|
||||
boost::algorithm::trim (strValue);
|
||||
|
||||
if (!strValue.empty ())
|
||||
secResult[strSection].push_back (strValue);
|
||||
}
|
||||
|
||||
@@ -751,6 +751,42 @@ trustthesevalidators.gov
|
||||
BEAST_EXPECT(wss.admin_ip && (wss.admin_ip .get().size() == 1));
|
||||
}
|
||||
|
||||
void testWhitespace()
|
||||
{
|
||||
Config cfg;
|
||||
/* NOTE: this string includes some explicit
|
||||
* space chars in order to verify proper trimming */
|
||||
std::string toLoad(R"(
|
||||
[port_rpc])" "\x20" R"(
|
||||
# comment
|
||||
# indented comment
|
||||
)" "\x20\x20" R"(
|
||||
[ips])" "\x20" R"(
|
||||
r.ripple.com 51235
|
||||
|
||||
[ips_fixed])" "\x20\x20" R"(
|
||||
# COMMENT
|
||||
s1.ripple.com 51235
|
||||
s2.ripple.com 51235
|
||||
|
||||
)");
|
||||
cfg.loadFromString (toLoad);
|
||||
BEAST_EXPECT (
|
||||
cfg.exists ("port_rpc") &&
|
||||
cfg.section ("port_rpc").lines ().empty () &&
|
||||
cfg.section ("port_rpc").values ().empty ());
|
||||
BEAST_EXPECT (
|
||||
cfg.exists (SECTION_IPS) &&
|
||||
cfg.section (SECTION_IPS).lines ().size () == 1 &&
|
||||
cfg.section (SECTION_IPS).values ().size () == 1);
|
||||
BEAST_EXPECT (
|
||||
cfg.exists (SECTION_IPS_FIXED) &&
|
||||
cfg.section (SECTION_IPS_FIXED).lines ().size () == 2 &&
|
||||
cfg.section (SECTION_IPS_FIXED).values ().size () == 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void run () override
|
||||
{
|
||||
testLegacy ();
|
||||
@@ -760,6 +796,7 @@ trustthesevalidators.gov
|
||||
testSetup (false);
|
||||
testSetup (true);
|
||||
testPort ();
|
||||
testWhitespace ();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user