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

fix: unquote quoted URL's to avoid libcurl errors #2596

Merged
Merged
Changes from all 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
17 changes: 13 additions & 4 deletions userspace/falco/outputs_http.cpp
Original file line number Diff line number Diff line change
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