pull/194/merge
M66B 3 years ago
parent 33cfc3b316
commit 9b3449f033

@ -4483,8 +4483,7 @@ A message will be consired safely transported if *every* [Received](https://data
* has a *with* with the value 'HTTP', 'HTTPS', or 'HTTPREST'
* has a *with* with the value '[xMTPSx](https://datatracker.ietf.org/doc/html/rfc3848)' ('xMTPAx' is considered insecure)
A local address is a local host address, a site local address
or a non-numeric address which isn't [a domain name](https://developer.android.com/reference/androidx/core/util/PatternsCompat#DOMAIN_NAME).
A local address is a local host address, a site local address or a link local address.
Example:

@ -509,7 +509,9 @@ public class ConnectionHelper {
static boolean isLocalAddress(String host) {
try {
InetAddress addr = ConnectionHelper.from6to4(InetAddress.getByName(host));
return (addr.isSiteLocalAddress() || addr.isLinkLocalAddress());
return (addr.isLoopbackAddress() ||
addr.isSiteLocalAddress() ||
addr.isLinkLocalAddress());
} catch (UnknownHostException ex) {
Log.e(ex);
return false;

@ -2202,18 +2202,26 @@ public class MessageHelper {
private static boolean isLocal(String value) {
if (value.contains("localhost") ||
value.contains("[127.0.0.1]") ||
value.contains("127.0.0.1") ||
value.contains("[::1]"))
return true;
int s = value.indexOf('[');
int e = value.indexOf(']', s + 1);
if (s >= 0 && e > 0) {
String ip = value.substring(s + 1, e);
if (ConnectionHelper.isNumericAddress(ip) &&
ConnectionHelper.isLocalAddress(ip))
return true;
}
int f = value.indexOf(' ');
String host = (f < 0 ? value : value.substring(0, f));
if (ConnectionHelper.isNumericAddress(host)) {
if (ConnectionHelper.isLocalAddress(host))
return true;
} else {
if (!PatternsCompat.DOMAIN_NAME.matcher(host).matches())
return true;
}
return false;
}

Loading…
Cancel
Save