Skip to content

curl_url_get for CURLUPART_HOST returns percent decoded string #14942

Closed
@muttalkadavul

Description

@muttalkadavul

I did this

#include <string>
#include <regex>
#include <tuple>
#include <iostream>
#include <curl/curl.h>


int main() {
    std::string input = "http://resum%c3%a9.com";
    CURLUcode rc = CURLUE_BAD_HANDLE;
    CURLU *urlh = curl_url();
    
    std::cout << "libcurl version" << curl_version() << std::endl;
 
    rc = curl_url_set(urlh, CURLUPART_URL, input.c_str(), 0);
    if(rc != CURLUE_OK)
    {
        std::cout << "curlucode = " << rc << std::endl;
        curl_url_cleanup(urlh);
    }

    char *host; 
    rc = curl_url_get(urlh, CURLUPART_HOST, &host, 0);
    if (rc != CURLUE_OK)
    {
        std::cout << "curlucode = " << rc << std::endl;
        curl_url_cleanup(urlh);
    }

    std::cout << host << std::endl; 
    free(host);
    curl_url_cleanup(urlh);
    return 0;
}

I expected the following

libcurl versionlibcurl/8.10.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libpsl/0.21.0
resum%c3%a9.com

but the actual output was


libcurl versionlibcurl/8.10.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libpsl/0.21.0
resumé.com

curl/libcurl version

libcurl/8.10.0

operating system

Ubuntu 20.04

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions