forked from Mirrors/privacore-open-source-search-engine
Fix bug in UrlComponent where wrong range of hex was checked.
Invalid % encoding should encode % instead of deleting it
This commit is contained in:
@ -15,7 +15,7 @@ void UrlComponent::normalize( std::string *component ) {
|
||||
if ( hexLen == 2 ) {
|
||||
// list is based on RFC 3986
|
||||
// https://tools.ietf.org/html/rfc3986#section-2.3
|
||||
if ( ( value >= 0x41 && value <= 0x51 ) ||
|
||||
if ( ( value >= 0x41 && value <= 0x5A ) ||
|
||||
( value >= 0x61 && value <= 0x7A ) ||
|
||||
( value >= 0x30 && value <= 0x39 ) ||
|
||||
( value == 0x2D ) || ( value == 0x2E ) || ( value == 0x5F ) || ( value == 0x7E ) ) {
|
||||
@ -32,8 +32,8 @@ void UrlComponent::normalize( std::string *component ) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// invalid url encoded (nothing much we can do)
|
||||
component->erase( percentPos, hexLen + 1 );
|
||||
// invalid url encoded (encode percent)
|
||||
component->insert( percentPos + 1, "25" );
|
||||
}
|
||||
}
|
||||
++percentPos;
|
||||
|
@ -710,7 +710,7 @@ TEST( UrlTest, Normalization ) {
|
||||
"http://www.huffingtonpost.com.au/entry/tiny-moments-happiness_us_56ec1a35e4b084c672200a36?section=australia&adsSiteOverride=au" ),
|
||||
std::make_tuple( "http://www.example.com/%7ejoe/index.html", "http://www.example.com/~joe/index.html" ),
|
||||
std::make_tuple( "http://www.example.com/jo%e9/index.html", "http://www.example.com/jo%E9/index.html" ),
|
||||
std::make_tuple( "http://www.example.com/%7joe/index.html", "http://www.example.com/joe/index.html" )
|
||||
std::make_tuple( "http://www.example.com/%7joe/index.html", "http://www.example.com/%257joe/index.html" )
|
||||
};
|
||||
|
||||
strip_param_tests( test_cases, 123 );
|
||||
|
Reference in New Issue
Block a user