mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 23:12:44 +01:00
libutil: Refactor percentDecode,percentEncode to use Boost.URL
The myriad of hand-rolled URL parsing and validation code is a constant source of problems. Regexes are not a great way of writing parsers and there's a history of getting them wrong. Boost.URL is a good library we can outsource most of the heavy lifting to.
This commit is contained in:
parent
d9053390ce
commit
ad449c0288
4 changed files with 25 additions and 29 deletions
|
|
@ -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 {
|
||||
|
||||
|
|
@ -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
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue