mirror of
				https://github.com/saitohirga/WSJT-X.git
				synced 2025-10-25 10:00:23 -04:00 
			
		
		
		
	Trim spaces from network server query
Spaces left in the CAT network server cause incorrect servername lookups, particularly just spaces which override the default values. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.4@4468 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
		
							parent
							
								
									bfa64afe06
								
							
						
					
					
						commit
						fc33d1b4c5
					
				| @ -6,11 +6,13 @@ | |||||||
| #include <QString> | #include <QString> | ||||||
| 
 | 
 | ||||||
| std::tuple<QHostAddress, quint16> | std::tuple<QHostAddress, quint16> | ||||||
| network_server_lookup (QString const& query | network_server_lookup (QString query | ||||||
| 		       , quint16 default_service_port | 		       , quint16 default_service_port | ||||||
| 		       , QHostAddress default_host_address | 		       , QHostAddress default_host_address | ||||||
| 		       , QAbstractSocket::NetworkLayerProtocol required_protocol) | 		       , QAbstractSocket::NetworkLayerProtocol required_protocol) | ||||||
| { | { | ||||||
|  |   query = query.trimmed (); | ||||||
|  | 
 | ||||||
|   QHostAddress host_address {default_host_address}; |   QHostAddress host_address {default_host_address}; | ||||||
|   quint16 service_port {default_service_port}; |   quint16 service_port {default_service_port}; | ||||||
| 
 | 
 | ||||||
| @ -31,11 +33,12 @@ network_server_lookup (QString const& query | |||||||
|           port_colon_index = query.lastIndexOf (':'); |           port_colon_index = query.lastIndexOf (':'); | ||||||
|           host_name = query.left (port_colon_index); |           host_name = query.left (port_colon_index); | ||||||
|         } |         } | ||||||
|  |       host_name = host_name.trimmed (); | ||||||
| 
 | 
 | ||||||
|       if (port_colon_index >= 0) |       if (port_colon_index >= 0) | ||||||
|         { |         { | ||||||
|           bool ok; |           bool ok; | ||||||
| 	  service_port = query.mid (port_colon_index + 1).toUShort (&ok); |           service_port = query.mid (port_colon_index + 1).trimmed ().toUShort (&ok); | ||||||
|           if (!ok) |           if (!ok) | ||||||
|             { |             { | ||||||
|               throw std::runtime_error {"network server lookup error: invalid port"}; |               throw std::runtime_error {"network server lookup error: invalid port"}; | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ class QString; | |||||||
| // returned in the first member of the result tuple.
 | // returned in the first member of the result tuple.
 | ||||||
| //
 | //
 | ||||||
| std::tuple<QHostAddress, quint16> | std::tuple<QHostAddress, quint16> | ||||||
| network_server_lookup (QString const& query | network_server_lookup (QString query | ||||||
| 		       , quint16 default_service_port | 		       , quint16 default_service_port | ||||||
| 		       , QHostAddress default_host_address = QHostAddress::LocalHost | 		       , QHostAddress default_host_address = QHostAddress::LocalHost | ||||||
| 		       , QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::AnyIPProtocol); | 		       , QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::AnyIPProtocol); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user