Skip to content

Commit

Permalink
fix: unquote quoted URL's to avoid libcurl errors
Browse files Browse the repository at this point in the history
This commit will unquote URL's allowing them to be supported by
libcurl and eliminate any errors when a valid (quoted) URL is supplied
by a user.

Closes #2579

Signed-off-by: Daniel Wright danielwright@bitgo.com
  • Loading branch information
therealdwright committed Jun 1, 2023
1 parent 25d2316 commit 58fa129
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions userspace/falco/outputs_http.cpp
Expand Up @@ -38,9 +38,18 @@ void falco::outputs::output_http::output(const message *msg)

if(res == CURLE_OK)
{
res = curl_easy_setopt(curl, CURLOPT_URL, m_oc.options["url"].c_str());
// if the URL is quoted the quotes should be removed to satisfy libcurl expected format
std::string unquotedUrl = m_oc.options["url"];
if (!unquotedUrl.empty() && (
(unquotedUrl.front() == '\"' && unquotedUrl.back() == '\"') ||
(unquotedUrl.front() == '\'' && unquotedUrl.back() == '\'')
))
{
unquotedUrl = libsinsp::filter::unescape_str(unquotedUrl);
}
res = curl_easy_setopt(curl, CURLOPT_URL, unquotedUrl.c_str());
}

if(res == CURLE_OK)
{
res = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, msg->msg.c_str());
Expand All @@ -55,7 +64,7 @@ void falco::outputs::output_http::output(const message *msg)
{
res = curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, -1L);
}

if(res == CURLE_OK)
{
if(m_oc.options["insecure"] == std::string("true"))
Expand All @@ -81,7 +90,7 @@ void falco::outputs::output_http::output(const message *msg)
res = curl_easy_setopt(curl, CURLOPT_CAPATH, m_oc.options["ca_path"].c_str());
}
}

if(res == CURLE_OK)
{
res = curl_easy_perform(curl);
Expand Down

0 comments on commit 58fa129

Please sign in to comment.