1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-10 04:26:01 +01:00

Merge pull request #13445 from xokdvium/simplify-util-url

libutil: Use Boost.URL for URI parsing
This commit is contained in:
Jörg Thalheim 2025-08-04 19:46:58 +02:00 committed by GitHub
commit c7af923865
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 192 additions and 81 deletions

View file

@ -1,5 +1,7 @@
#include "nix/util/url.hh"
#include "nix/util/tests/gmock-matchers.hh"
#include <gtest/gtest.h>
#include <gmock/gmock.h>
namespace nix {
@ -122,9 +124,9 @@ TEST(parseURL, parseIPv4Address)
ASSERT_EQ(parsed, expected);
}
TEST(parseURL, parseScopedRFC4007IPv6Address)
TEST(parseURL, parseScopedRFC6874IPv6Address)
{
auto s = "http://[fe80::818c:da4d:8975:415c\%enp0s25]:8080";
auto s = "http://[fe80::818c:da4d:8975:415c\%25enp0s25]:8080";
auto parsed = parseURL(s);
ParsedURL expected{
@ -289,6 +291,14 @@ TEST(percentDecode, trailingPercent)
ASSERT_EQ(d, s);
}
TEST(percentDecode, incompleteEncoding)
{
ASSERT_THAT(
[]() { percentDecode("%1"); },
::testing::ThrowsMessage<BadURL>(
testing::HasSubstrIgnoreANSIMatcher("error: invalid URI parameter '%1': incomplete pct-encoding")));
}
/* ----------------------------------------------------------------------------
* percentEncode
* --------------------------------------------------------------------------*/