uri: percent encode spaces prior to parsing
This simplifies the use of our overly strict parser.
This commit is contained in:
parent
1664c283c0
commit
2e645cc82d
13
uri.cpp
13
uri.cpp
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user