Skip to content

curl_url_set fails for encoded hostname #14656

Description

@muttalkadavul

I did this

int main() 
{
    std::string input = "resum%33%35.com";
    CURLUcode rc = CURLUE_BAD_HANDLE;
    CURLU *urlh = curl_url();

    rc = curl_url_set(urlh, CURLUPART_HOST, input.c_str(), 0);
    if(rc != CURLUE_OK)
    {
        std::cout << "curlucode = " << rc << std::endl;
        curl_url_cleanup(urlh);
    }
    
    std::cout << "Hostname: " << input << std::endl;
    std::cout << "libcurl version" << curl_version() << std::endl;
    return 0;
} 

I expected the following

I expected it to return CURLUE_OK but got this

curlucode = 21
Hostname: resum%33%35.com
libcurl versionlibcurl/8.9.1 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libpsl/0.21.0

When I run the above code with an older curl I get

Hostname: resum%33%35.com
libcurl versionlibcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3

No error!

curl/libcurl version

libcurl versionlibcurl/8.9.1 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libpsl/0.21.0

operating system

Ubuntu 22.04

Activity

  1. self-assigned this
    on Aug 23, 2024
  2. bagder commented on Aug 23, 2024

    @bagder
    Member

    Confirmed. The problem is that the hostname check function is called with the URL encoded host name as input and not the decoded version so it thinks the % in there is invalid.

    Regression from 0a0c9b6

    PR coming up.

  3. muttalkadavul commented on Aug 23, 2024

    @muttalkadavul
    Author

    That was quick! Thanks!

  4. added a commit that references this issue on Aug 23, 2024
    a28ae82
  5. added a commit that references this issue on Aug 23, 2024
    d1394a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions