Skip to content

Parsing anchor links changes path/query of URL #15836

Closed
@jeroen

Description

@jeroen

I did this

When parsing anchor-only links #section from a html page, the path and query sometimes change. For example:

#include <stdio.h>
#include <string.h>
#include <curl/curl.h>

int main(void){
  curl_global_init(CURL_GLOBAL_DEFAULT);
  CURLU *h = curl_url();
  curl_url_set(h, CURLUPART_URL, "https://x.com/a/b/c?x=123", 0); //base url
  curl_url_set(h, CURLUPART_URL, "#bar", 0); //href
  char *str = NULL;
  CURLUcode err = curl_url_get(h, CURLUPART_URL, &str, 0);
  printf("%s\n", str);
  return 0;
}

I think the correct value here should be https://x.com/a/b/c?x=123#bar.

However on MacOS (curl 8.7.1) it is: https://x.com/a/b/#bar (both the path and query have changed).

On Debian Linux (8.11.1) it is: https://x.com/a/b/c#bar (the query has changed).

I expected the following

The url with #bar appended and no changes to the path or query.

curl/libcurl version

curl 8.11.1

operating system

MacOS / Debian

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions