Commit ae14ccff authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Fix integration of wildcard host lists by treating "*." as all subdomains...

Fix integration of wildcard host lists by treating "*." as all subdomains (including no subdomain) of a host

Ref: https://github.com/badmojr/1Hosts/pull/139
parent afff8547
...@@ -407,6 +407,7 @@ class RuleImportService : IntentService("RuleImportService") { ...@@ -407,6 +407,7 @@ class RuleImportService : IntentService("RuleImportService") {
} }
private val wildcardNormalisationRegex = Regex("(?:^\\*\\*\\.)|(\\.\\*\\*$)") private val wildcardNormalisationRegex = Regex("(?:^\\*\\*\\.)|(\\.\\*\\*$)")
private val leadingWildcardRegex = Regex("^\\*\\.")
private fun createRule( private fun createRule(
host: String, host: String,
target: String, target: String,
...@@ -419,10 +420,10 @@ class RuleImportService : IntentService("RuleImportService") { ...@@ -419,10 +420,10 @@ class RuleImportService : IntentService("RuleImportService") {
if (it.contains("*")) { if (it.contains("*")) {
isWildcard = true isWildcard = true
if (source.isFileSource) { if (source.isFileSource) {
it.replace("**", "%%").replace("*", "%") it.replace(leadingWildcardRegex, "**").replace("**", "%%").replace("*", "%")
.replace(wildcardNormalisationRegex, "**") .replace(wildcardNormalisationRegex, "**")
} else { } else {
it.replace("**", "%%").replace("*", "%%") it.replace(leadingWildcardRegex, "**").replace("**", "%%").replace("*", "%%")
.replace(wildcardNormalisationRegex, "**") .replace(wildcardNormalisationRegex, "**")
} }
} else it } else it
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment