diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2023-08-18 17:08:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-18 17:08:03 +0200 |
commit | 735558bea6f89af39609da01177a20685cdd2718 (patch) | |
tree | c6afa79895c7c84aba289ee98b40c99e1a4f7d16 | |
parent | 284c18073233b3c7e7e027d696465a0e773dc881 (diff) | |
parent | 73696ec71678433dac87863bab36b66701d4b6ed (diff) |
Merge pull request #8845 from cole-h/fix-double-percent-encoding
libutil: fix double-encoding of URLs
-rw-r--r-- | src/libexpr/tests/flakeref.cc | 22 | ||||
-rw-r--r-- | src/libutil/url.cc | 2 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/libexpr/tests/flakeref.cc b/src/libexpr/tests/flakeref.cc new file mode 100644 index 000000000..2b7809b93 --- /dev/null +++ b/src/libexpr/tests/flakeref.cc @@ -0,0 +1,22 @@ +#include <gtest/gtest.h> + +#include "flake/flakeref.hh" + +namespace nix { + +/* ----------- tests for flake/flakeref.hh --------------------------------------------------*/ + + /* ---------------------------------------------------------------------------- + * to_string + * --------------------------------------------------------------------------*/ + + TEST(to_string, doesntReencodeUrl) { + auto s = "http://localhost:8181/test/+3d.tar.gz"; + auto flakeref = parseFlakeRef(s); + auto parsed = flakeref.to_string(); + auto expected = "http://localhost:8181/test/%2B3d.tar.gz"; + + ASSERT_EQ(parsed, expected); + } + +} diff --git a/src/libutil/url.cc b/src/libutil/url.cc index 9e44241ac..a8f7d39fd 100644 --- a/src/libutil/url.cc +++ b/src/libutil/url.cc @@ -44,7 +44,7 @@ ParsedURL parseURL(const std::string & url) .base = base, .scheme = scheme, .authority = authority, - .path = path, + .path = percentDecode(path), .query = decodeQuery(query), .fragment = percentDecode(std::string(fragment)) }; |