From 513bd2cec9588a10c80b146872d6efc22e0b85eb Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 9 Nov 2023 23:46:25 +0100 Subject: [PATCH] Allow placeholders in Autoconfig `domain` elements --- .../app/k9mail/autodiscovery/autoconfig/RealAutoconfigParser.kt | 2 +- .../k9mail/autodiscovery/autoconfig/RealAutoconfigParserTest.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/feature/autodiscovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigParser.kt b/feature/autodiscovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigParser.kt index c8f8e04c056..e0424e61e0b 100644 --- a/feature/autodiscovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigParser.kt +++ b/feature/autodiscovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigParser.kt @@ -112,7 +112,7 @@ private class ClientConfigParser( if (eventType == XmlPullParser.START_TAG) { when (pullParser.name) { "domain" -> { - val domain = readText() + val domain = readText().replaceVariables() if (domain.isValidHostname()) { domainFound = true } diff --git a/feature/autodiscovery/autoconfig/src/test/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigParserTest.kt b/feature/autodiscovery/autoconfig/src/test/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigParserTest.kt index 3c4c9896a00..f2663ca26c2 100644 --- a/feature/autodiscovery/autoconfig/src/test/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigParserTest.kt +++ b/feature/autodiscovery/autoconfig/src/test/kotlin/app/k9mail/autodiscovery/autoconfig/RealAutoconfigParserTest.kt @@ -112,6 +112,7 @@ class RealAutoconfigParserTest { @Test fun `replace variables`() { val inputStream = minimalConfig.withModifications { + element("domain").text("%EMAILDOMAIN%") element("incomingServer > hostname").text("%EMAILLOCALPART%.domain.example") element("outgoingServer > hostname").text("%EMAILLOCALPART%.outgoing.domain.example") element("outgoingServer > username").text("%EMAILDOMAIN%")