uri: percent encode spaces prior to parsing

This simplifies the use of our overly strict parser.
This commit is contained in:
Danny Robson 2022-02-25 07:16:21 +10:00
parent 1664c283c0
commit 2e645cc82d

13
uri.cpp
View File

@ -11,6 +11,17 @@
using cruft::uri;
///////////////////////////////////////////////////////////////////////////////
static void
minimal_percent_encode (std::string &str)
{
for (ssize_t i = 0; i < std::ssize (str); ++i) {
if (str[i] == ' ')
str.replace (i, 1, "%20");
}
}
///////////////////////////////////////////////////////////////////////////////
cruft::uri::uri (std::string &&_value):
m_views {
@ -24,6 +35,8 @@ cruft::uri::uri (std::string &&_value):
},
m_value (std::move (_value))
{
minimal_percent_encode (m_value);
parse ();
if (m_views[0].begin () == nullptr)