From c03b70ddac588984167880ca3d3fad1b37c17b42 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 4 Oct 2014 21:50:35 +0200 Subject: [PATCH] Strip IP address from IP address / domain name pair for better wildcards Fixes #2014 --- CHANGELOG.md | 2 ++ src/biz/bokhorst/xprivacy/PrivacyService.java | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) 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..54e32c052 100644 --- a/src/biz/bokhorst/xprivacy/PrivacyService.java +++ b/src/biz/bokhorst/xprivacy/PrivacyService.java @@ -443,6 +443,13 @@ else if (hook.getFrom() != null) { } } + // Process IP address + if (restriction.extra != null && Meta.cTypeIPAddress.equals(hook.whitelist())) { + int slash = restriction.extra.indexOf('/'); + if (slash >= 0) + restriction.extra = restriction.extra.substring(slash + 1); + } + // Check for system component if (!PrivacyManager.isApplication(restriction.uid)) if (!getSettingBool(userId, PrivacyManager.cSettingSystem, false)) @@ -1976,13 +1983,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) + ".*"