Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Strip IP address from IP address / domain name pair for better wildcards
Browse files Browse the repository at this point in the history
Fixes #2014
  • Loading branch information
M66B committed Oct 4, 2014
1 parent 91fad02 commit c03b70d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
14 changes: 7 additions & 7 deletions src/biz/bokhorst/xprivacy/PrivacyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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) + ".*"
Expand Down

0 comments on commit c03b70d

Please sign in to comment.