Page MenuHomeFreeBSD

libfetch: don't include fragments in HTTP requests
ClosedPublic

Authored by gahr on Aug 19 2024, 7:54 AM.
Tags
None
Referenced Files
F102941561: D46318.diff
Tue, Nov 19, 12:54 AM
Unknown Object (File)
Sun, Nov 10, 10:28 PM
Unknown Object (File)
Sun, Nov 10, 10:27 PM
Unknown Object (File)
Fri, Nov 1, 9:27 PM
Unknown Object (File)
Oct 2 2024, 2:07 PM
Unknown Object (File)
Oct 2 2024, 10:07 AM
Unknown Object (File)
Oct 2 2024, 4:50 AM
Unknown Object (File)
Oct 1 2024, 8:13 PM
Subscribers

Details

Summary

Fragments are reserved for client-side processing, see
https://www.rfc-editor.org/rfc/rfc9110.html#section-7.1

Also, some servers don't like to receive HTTP requests with fragments.

$ fetch 'https://dropbox.com/a/b'
fetch: https://dropbox.com/a/b: Not Found

$ fetch 'https://dropbox.com/a/b#'
fetch: https://dropbox.com/a/b#: Bad Request

This is a real-world scenario, where some download link from dropbox
(eventually) redirects to an URL with a fragment:

$ fetch -v 'https://www.dropbox.com/sh/<some>/<thing>?dl=1' 2>&1 | grep requesting
requesting https://www.dropbox.com/sh/<some>/<thing>?dl=1
requesting https://www.dropbox.com/scl/fo/<foo>/<bar>?rlkey=<baz>&dl=1
requesting https://<boo>.dl.dropboxusercontent.com/zip_download_get/<some-long-strig>#

See how the last redirect ends with a #.

Currently, libfetch includes the ending fragment and makes it impossible
to download the file.

Test Plan

manually tested

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 59048
Build 55935: arc lint + arc unit

Event Timeline

gahr requested review of this revision.Aug 19 2024, 7:54 AM
des requested changes to this revision.Aug 19 2024, 8:49 AM

This belongs in the URL parser, not in the HTTP client.

This revision now requires changes to proceed.Aug 19 2024, 8:49 AM
In D46318#1056275, @des wrote:

This belongs in the URL parser, not in the HTTP client.

I was unsure whether the URL parser should terminate the doc part at the first fragment or not. The reason I did it in the http module is that I don't know if any other protocols supported by libfetch might use the fragment for anything. E.g., should fetch file:///path/to/file#foo fetch a file named 'file#foo'?

In D46318#1056275, @des wrote:

This belongs in the URL parser, not in the HTTP client.

I was unsure whether the URL parser should terminate the doc part at the first fragment or not. The reason I did it in the http module is that I don't know if any other protocols supported by libfetch might use the fragment for anything. E.g., should fetch file:///path/to/file#foo fetch a file named 'file#foo'?

The URL parser knows which protocol it's dealing with.

Handle fragments while parsing the URL

This revision is now accepted and ready to land.Aug 21 2024, 10:46 AM