Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtc.confのバックスラッシュの後にスペースがある場合、urlparam2mapで空白のパラメータがある場合に設定を無視する #1028

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions src/lib/coil/common/coil/Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ namespace coil
*/
const std::string& Properties::getProperty(const std::string& key) const
{
if (coil::eraseBothEndsBlank(key).empty())
{
return m_empty;
}
std::vector<std::string> keys;
split(key, '.', keys);
Properties* node(nullptr);
Expand All @@ -190,6 +194,10 @@ namespace coil
const std::string& Properties::getProperty(const std::string& key,
const std::string& def) const
{
if (coil::eraseBothEndsBlank(key).empty())
{
return m_empty;
}
const std::string& invalue((*this)[key]);

return invalue.empty() ? def : invalue;
Expand Down Expand Up @@ -232,6 +240,12 @@ namespace coil
const std::string& Properties::getDefault(const std::string& key) const
{
std::vector<std::string> keys;

if (coil::eraseBothEndsBlank(key).empty())
{
return m_empty;
}

split(key, '.', keys);
Properties* node(nullptr);
if ((node = _getNode(keys, 0, this)) != nullptr)
Expand All @@ -252,6 +266,12 @@ namespace coil
const std::string& invalue)
{
std::vector<std::string> keys;

if (coil::eraseBothEndsBlank(key).empty())
{
return m_empty;
}

split(key, '.', keys);

Properties* curr(this);
Expand Down Expand Up @@ -282,6 +302,10 @@ namespace coil
std::string Properties::setDefault(const std::string& key,
const std::string& invalue)
{
if (coil::eraseBothEndsBlank(key).empty())
{
return m_empty;
}
std::vector<std::string> keys;
split(key, '.', keys);

Expand Down Expand Up @@ -345,7 +369,7 @@ namespace coil

while (!inStream.eof())
{
std::string tmp{coil::eraseHeadBlank(coil::getlinePortable(inStream))};
std::string tmp{coil::eraseBothEndsBlank(coil::getlinePortable(inStream))};

// Skip comments or empty lines
if (tmp.empty())
Expand Down Expand Up @@ -448,7 +472,7 @@ namespace coil
*/
Properties* Properties::findNode(const std::string& key) const
{
if (key.empty())
if (coil::eraseBothEndsBlank(key).empty())
{
return nullptr;
}
Expand All @@ -466,7 +490,7 @@ namespace coil
*/
Properties& Properties::getNode(const std::string& key)
{
if (key.empty())
if (coil::eraseBothEndsBlank(key).empty())
{
return *this;
}
Expand All @@ -488,7 +512,7 @@ namespace coil
*/
bool Properties::createNode(const std::string& key)
{
if (key.empty())
if (coil::eraseBothEndsBlank(key).empty())
{
return false;
}
Expand Down Expand Up @@ -534,6 +558,10 @@ namespace coil
*/
Properties* Properties::hasKey(const char* key) const
{
if (coil::eraseBothEndsBlank(key).empty())
{
return nullptr;
}
for (auto prop : leaf)
{
if (prop->name == key)
Expand Down
10 changes: 9 additions & 1 deletion src/lib/coil/common/coil/stringutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,18 @@ namespace coil
std::map<std::string, std::string> retmap;
for (auto & param : params)
{
if (coil::eraseBothEndsBlank(param).empty())
{
continue;
}
std::string::size_type pos = param.find('=');
if (pos != std::string::npos)
{
retmap[param.substr(0, pos)] = param.substr(pos + 1);
const std::string key{param.substr(0, pos)};
if (!coil::eraseBothEndsBlank(key).empty())
{
retmap[key] = param.substr(pos + 1);
}
}
else
{
Expand Down