ISSUES-995 fix cut www

This commit is contained in:
zhang2014 2018-02-20 09:34:50 +08:00
parent 3f8c42c97d
commit 219de205e3

View File

@ -396,20 +396,41 @@ struct ExtractWWW
Pos pos = data;
Pos end = pos + size;
if (nullptr != (pos = strchr(pos, '/')))
{
if (pos != data)
{
Pos tmp;
size_t protocol_length;
ExtractProtocol::execute(data, size, tmp, protocol_length);
pos += protocol_length + 3;
if (pos >= end || pos[-1] != '/' || pos[-2] != '/')
if (pos != data + protocol_length + 1)
return;
}
if (end - pos < 2 || *(pos++) != '/' || *(pos++) != '/')
return;
if (pos + 4 < end && !strncmp(pos, "www.", 4))
const char *st = pos;
for (; pos < end; ++pos)
{
res_data = pos;
if (*pos == '@')
{
st = pos + 1;
} else if (*pos == ':' || *pos == '/' || *pos == '?' || *pos == '#')
{
break;
}
}
if (st + 4 < end && !strncmp(st, "www.", 4))
{
res_data = st;
res_size = 4;
}
}
}
};