forked from OSchip/llvm-project
[LLDB] Fix parsing of IPv6 host:port inside brackets
Summary: When using IPv6 host:port pairs, typically the host is put inside brackets, such as [2601🔢...:0213]:5555, and the UriParser can handle this format. However, the Android infrastructure in LLDB assumes an additional brackets around the host:port pair, such that the entire host:port string can be treated as the host (which is used as an Android Serial Number), and UriParser cannot handle multiple brackets. Parsing inputs with such extra backets requires searching the closing bracket from the right. Test: BracketedHostnameWithPortIPv6 covers the case mentioned above Reviewers: #lldb, labath Reviewed By: labath Subscribers: kwk, shafik, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D76736
This commit is contained in:
parent
a945037e8f
commit
57be22fa17
|
@ -42,7 +42,7 @@ bool UriParser::Parse(llvm::StringRef uri, llvm::StringRef &scheme,
|
|||
// Extract hostname
|
||||
if (!host_port.empty() && host_port[0] == '[') {
|
||||
// hostname is enclosed with square brackets.
|
||||
pos = host_port.find(']');
|
||||
pos = host_port.rfind(']');
|
||||
if (pos == std::string::npos)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -74,12 +74,19 @@ TEST(UriParserTest, LongPath) {
|
|||
VALIDATE
|
||||
}
|
||||
|
||||
TEST(UriParserTest, TypicalPortPath) {
|
||||
TEST(UriParserTest, TypicalPortPathIPv4) {
|
||||
const UriTestCase testCase("connect://192.168.100.132:5432/", "connect",
|
||||
"192.168.100.132", 5432, "/");
|
||||
VALIDATE;
|
||||
}
|
||||
|
||||
TEST(UriParserTest, TypicalPortPathIPv6) {
|
||||
const UriTestCase testCase(
|
||||
"connect://[2601:600:107f:db64:a42b:4faa:284:3082]:5432/", "connect",
|
||||
"2601:600:107f:db64:a42b:4faa:284:3082", 5432, "/");
|
||||
VALIDATE;
|
||||
}
|
||||
|
||||
TEST(UriParserTest, BracketedHostnamePort) {
|
||||
const UriTestCase testCase("connect://[192.168.100.132]:5432/", "connect",
|
||||
"192.168.100.132", 5432, "/");
|
||||
|
@ -102,6 +109,21 @@ TEST(UriParserTest, BracketedHostname) {
|
|||
VALIDATE
|
||||
}
|
||||
|
||||
TEST(UriParserTest, BracketedHostnameWithPortIPv4) {
|
||||
// Android device over IPv4: port is a part of the hostname.
|
||||
const UriTestCase testCase("connect://[192.168.100.132:1234]", "connect",
|
||||
"192.168.100.132:1234", -1, "/");
|
||||
VALIDATE
|
||||
}
|
||||
|
||||
TEST(UriParserTest, BracketedHostnameWithPortIPv6) {
|
||||
// Android device over IPv6: port is a part of the hostname.
|
||||
const UriTestCase testCase(
|
||||
"connect://[[2601:600:107f:db64:a42b:4faa:284]:1234]", "connect",
|
||||
"[2601:600:107f:db64:a42b:4faa:284]:1234", -1, "/");
|
||||
VALIDATE
|
||||
}
|
||||
|
||||
TEST(UriParserTest, BracketedHostnameWithColon) {
|
||||
const UriTestCase testCase("connect://[192.168.100.132:5555]:1234", "connect",
|
||||
"192.168.100.132:5555", 1234, "/");
|
||||
|
|
Loading…
Reference in New Issue