Skip to content

Commit

Permalink
Merge pull request #8845 from cole-h/fix-double-percent-encoding
Browse files Browse the repository at this point in the history
libutil: fix double-encoding of URLs
  • Loading branch information
edolstra authored Aug 18, 2023
2 parents 284c180 + 73696ec commit 735558b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/libexpr/tests/flakeref.cc
Original file line number Diff line number Diff line change
@@ -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 = "https://localhost:8181/test/+3d.tar.gz";
auto flakeref = parseFlakeRef(s);
auto parsed = flakeref.to_string();
auto expected = "https://localhost:8181/test/%2B3d.tar.gz";

ASSERT_EQ(parsed, expected);
}

}
2 changes: 1 addition & 1 deletion src/libutil/url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
};
Expand Down

0 comments on commit 735558b

Please sign in to comment.