Skip to content

Commit 0a4504d

Browse files
Jeroen Habrakendeanberris
authored andcommitted
Prevent modification of the scheme
1 parent ae9371d commit 0a4504d

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

boost/network/uri/http/detail/parse_specific.hpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
// (See accompanying file LICENSE_1_0.txt of copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9-
#include <boost/algorithm/string/case_conv.hpp>
10-
9+
#include <boost/algorithm/string/predicate.hpp>
1110
#include <boost/network/uri/http/detail/uri_parts.hpp>
1211
#include <boost/network/uri/detail/parse_uri.hpp>
1312
#include <boost/network/traits/string.hpp>
@@ -54,20 +53,16 @@ namespace boost { namespace network { namespace uri {
5453
{
5554
namespace qi = spirit::qi;
5655

57-
// For resiliency, programs interpreting URI should treat upper
58-
// case letters as equivalent to lower case in scheme names
59-
boost::to_lower(parts.scheme);
60-
61-
// Require that parts.scheme is either http or https
62-
if (parts.scheme.size() < 4)
63-
return false;
64-
if (parts.scheme.substr(0, 4) != "http")
56+
// Require that parts.scheme is either http or https, case insensitive
57+
if (parts.scheme.size() < 4 or parts.scheme.size() > 5)
6558
return false;
66-
if (parts.scheme.size() == 5) {
67-
if (parts.scheme[4] != 's')
59+
if (parts.scheme.size() == 4) {
60+
if (not boost::iequals(parts.scheme.substr(0, 4), "http"))
6861
return false;
69-
} else if (parts.scheme.size() > 5)
70-
return false;
62+
} else { // size is 5
63+
if (not boost::iequals(parts.scheme.substr(0, 5), "https"))
64+
return false;
65+
}
7166

7267
typedef string<tags::http>::type string_type;
7368
typedef range_iterator<string_type>::type iterator;

0 commit comments

Comments
 (0)