Browse Source

URL decode hostname in addition to username and password

Paul-Louis Ageneau 3 years ago
parent
commit
c1ae522218
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/configuration.cpp

+ 5 - 2
src/configuration.cpp

@@ -80,10 +80,13 @@ IceServer::IceServer(const string &url) {
 	password = utils::url_decode(opt[8].value_or(""));
 	password = utils::url_decode(opt[8].value_or(""));
 
 
 	hostname = opt[10].value();
 	hostname = opt[10].value();
-	while (!hostname.empty() && hostname.front() == '[')
+	if(hostname.front() == '[' && hostname.back() == ']') {
+		// IPv6 literal
 		hostname.erase(hostname.begin());
 		hostname.erase(hostname.begin());
-	while (!hostname.empty() && hostname.back() == ']')
 		hostname.pop_back();
 		hostname.pop_back();
+	} else {
+		hostname = utils::url_decode(hostname);
+	}
 
 
 	string service = opt[12].value_or(relayType == RelayType::TurnTls ? "5349" : "3478");
 	string service = opt[12].value_or(relayType == RelayType::TurnTls ? "5349" : "3478");
 	try {
 	try {