diff --git a/CHANGELOG.md b/CHANGELOG.md index 7713192d9..6b0dd1bb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ See for more information about XPrivacy 3 [this FAQ](https://github.com/M66B/XPr **Next release** +* Strip IP address from IP address / domain name pair for better wildcards ([issue](/../../issues/2014)) + [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) **Version 3.3.3 BETA** diff --git a/src/biz/bokhorst/xprivacy/PrivacyService.java b/src/biz/bokhorst/xprivacy/PrivacyService.java index 8b479dc62..bfab95f62 100644 --- a/src/biz/bokhorst/xprivacy/PrivacyService.java +++ b/src/biz/bokhorst/xprivacy/PrivacyService.java @@ -443,6 +443,19 @@ else if (hook.getFrom() != null) { } } + // Process IP address + if (restriction.extra != null && Meta.cTypeIPAddress.equals(hook.whitelist())) { + int colon = restriction.extra.lastIndexOf(':'); + String address = (colon >= 0 ? restriction.extra.substring(0, colon) : restriction.extra); + String port = (colon >= 0 ? restriction.extra.substring(colon) : ""); + + int slash = address.indexOf('/'); + if (slash == 0) // IP address + restriction.extra = address.substring(slash + 1) + port; + else if (slash > 0) // Domain name + restriction.extra = address.substring(0, slash) + port; + } + // Check for system component if (!PrivacyManager.isApplication(restriction.uid)) if (!getSettingBool(userId, PrivacyManager.cSettingSystem, false)) @@ -1976,13 +1989,6 @@ private String[] getXExtra(PRestriction restriction, Hook hook) { // sub-domain or sub-net int colon = restriction.extra.lastIndexOf(':'); String address = (colon >= 0 ? restriction.extra.substring(0, colon) : restriction.extra); - - int slash = address.indexOf('/'); - if (slash == 0) - address = address.substring(slash + 1); // IP address - else if (slash > 0) - address = address.substring(0, slash); // domain name - if (Patterns.IP_ADDRESS.matcher(address).matches()) { int dot = address.lastIndexOf('.'); listResult.add(address.substring(0, dot) + ".*"