1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00
nix/src
Bernardo Meurer Costa e3b3f05e5d
fix(nix-prefetch-url): correctly extract filename from URLs with query parameters
Previously, `prefetchFile()` used `baseNameOf()` directly on the URL string
to extract the filename. This caused issues with URLs containing query
parameters that include slashes, such as S3 URLs with custom endpoints:

```
s3://bucket/file.txt?endpoint=http://server:9000
```

The `baseNameOf()` function naively searches for the rightmost `/` in the
entire string, which would find the `/` in `http://server:9000` and extract
`server:9000&region=...` as the filename. This resulted in invalid store
path names containing illegal characters like `:`.

This commit fixes the issue by:

1. Adding a `VerbatimURL::lastPathSegment()` method that extracts the last
   non-empty path segment from a URL, using `pathSegments(true)` to filter
   empty segments
2. Changing `prefetchFile()` to accept `const VerbatimURL &` and use the new
   `lastPathSegment()` method instead of manual path parsing
3. Adding early validation with `checkName()` to fail quickly on invalid
   filenames
4. Maintains backward compatibility by falling back to `baseNameOf()` for
   unparsable `VerbatimURL`s
2025-10-20 21:40:03 +03:00
..
external-api-docs meson: Apply formatting universally 2025-08-07 02:58:29 +03:00
internal-api-docs meson: Apply formatting universally 2025-08-07 02:58:29 +03:00
json-schema-checks Add JSON Schema infrastructure, use for Derivation 2025-10-16 17:24:18 -04:00
libcmd Factor out --no-check-sigs 2025-10-16 16:35:09 +02:00
libexpr Clarify unlocked input warning message 2025-10-19 14:08:34 +02:00
libexpr-c meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libexpr-test-support meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libexpr-tests meson: Simplify asan-options handling even more 2025-10-12 19:16:06 +03:00
libfetchers Merge pull request #14253 from NixOS/libgit2-refname-wa 2025-10-15 19:30:53 +00:00
libfetchers-c meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libfetchers-tests libfetchers/git-utils: Be more correct about validating refnames 2025-10-15 21:54:09 +03:00
libflake Clarify unlocked input warning message 2025-10-19 14:08:34 +02:00
libflake-c meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libflake-tests Remove unecessary includes 2025-10-14 23:48:45 -04:00
libmain meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libmain-c meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libstore Merge pull request #14301 from NixOS/s3-terminate-unknown-profile 2025-10-20 14:28:16 +00:00
libstore-c meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libstore-test-support meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libstore-tests Merge pull request #14226 from obsidiansystems/unkeyed-realisation 2025-10-15 21:27:13 +00:00
libutil fix(nix-prefetch-url): correctly extract filename from URLs with query parameters 2025-10-20 21:40:03 +03:00
libutil-c meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libutil-test-support meson: Move asan-options to common 2025-10-11 16:08:35 +03:00
libutil-tests Merge pull request #14232 from roberth/dyndrv-messages 2025-10-14 15:40:27 +00:00
nix fix(nix-prefetch-url): correctly extract filename from URLs with query parameters 2025-10-20 21:40:03 +03:00
perl Convert Realisation JSON logic to standard style 2025-09-22 12:59:37 -04:00
nix-functional-tests Build Functional tests with Meson 2024-08-14 15:35:40 -04:00
nix-manual Build the manual with Meson 2024-10-09 11:58:17 -04:00