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") {
}
private val wildcardNormalisationRegex = Regex("(?:^\\*\\*\\.)|(\\.\\*\\*$)")
private val leadingWildcardRegex = Regex("^\\*\\.")
private fun createRule(
host: String,
target: String,
......@@ -419,10 +420,10 @@ class RuleImportService : IntentService("RuleImportService") {
if (it.contains("*")) {
isWildcard = true
if (source.isFileSource) {
it.replace("**", "%%").replace("*", "%")
it.replace(leadingWildcardRegex, "**").replace("**", "%%").replace("*", "%")
.replace(wildcardNormalisationRegex, "**")
} else {
it.replace("**", "%%").replace("*", "%%")
it.replace(leadingWildcardRegex, "**").replace("**", "%%").replace("*", "%%")
.replace(wildcardNormalisationRegex, "**")
}
} 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