diff --git a/app/src/main/kotlin/com/svenjacobs/app/leon/startup/ContainerInitializer.kt b/app/src/main/kotlin/com/svenjacobs/app/leon/startup/ContainerInitializer.kt index 62e0ddca..bd2d548d 100644 --- a/app/src/main/kotlin/com/svenjacobs/app/leon/startup/ContainerInitializer.kt +++ b/app/src/main/kotlin/com/svenjacobs/app/leon/startup/ContainerInitializer.kt @@ -53,6 +53,7 @@ import com.svenjacobs.app.leon.core.domain.sanitizer.pearl.PearlSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.reddit.RedditMailSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.reddit.RedditOutSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.reddit.RedditSanitizer +import com.svenjacobs.app.leon.core.domain.sanitizer.salesforce.SalesforceParametersSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.sessionids.SessionIdsSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.shopee.ShopeeSanitizer import com.svenjacobs.app.leon.core.domain.sanitizer.spiegel.SpiegelSanitizer @@ -112,6 +113,7 @@ class ContainerInitializer : DistinctInitializer { RedditMailSanitizer(), RedditOutSanitizer(), RedditSanitizer(), + SalesforceParametersSanitizer(), SessionIdsSanitizer(), ShopeeSanitizer(), SpiegelSanitizer(), diff --git a/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/salesforce/SalesforceParametersSanitizer.kt b/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/salesforce/SalesforceParametersSanitizer.kt new file mode 100644 index 00000000..c9dbc268 --- /dev/null +++ b/core-domain/src/main/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/salesforce/SalesforceParametersSanitizer.kt @@ -0,0 +1,39 @@ +/* + * Léon - The URL Cleaner + * Copyright (C) 2024 Sven Jacobs + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.svenjacobs.app.leon.core.domain.sanitizer.salesforce + +import android.content.Context +import com.svenjacobs.app.leon.core.common.regex.RegexFactory +import com.svenjacobs.app.leon.core.domain.R +import com.svenjacobs.app.leon.core.domain.sanitizer.RegexSanitizer +import com.svenjacobs.app.leon.core.domain.sanitizer.Sanitizer +import com.svenjacobs.app.leon.core.domain.sanitizer.SanitizerId + +class SalesforceParametersSanitizer : + RegexSanitizer( + // see https://help.salesforce.com/s/articleView?id=sf.mc_gai_utm_parameters.htm&type=5 + RegexFactory.ofWildcardParameter("utm_|sfmc_"), + ) { + + override val id = SanitizerId("salesforce") + + override fun getMetadata(context: Context) = Sanitizer.Metadata( + name = context.getString(R.string.sanitizer_salesforce_name), + ) +} diff --git a/core-domain/src/main/res/values/strings.xml b/core-domain/src/main/res/values/strings.xml index 04f26877..15d4b104 100644 --- a/core-domain/src/main/res/values/strings.xml +++ b/core-domain/src/main/res/values/strings.xml @@ -50,6 +50,7 @@ Reddit Reddit (click.redditmail.com) Reddit (out.reddit.com) + Salesforce Session IDs Shopee Spiegel diff --git a/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/salesforce/SalesforceParametersSanitizerTest.kt b/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/salesforce/SalesforceParametersSanitizerTest.kt new file mode 100644 index 00000000..15c7faae --- /dev/null +++ b/core-domain/src/test/kotlin/com/svenjacobs/app/leon/core/domain/sanitizer/salesforce/SalesforceParametersSanitizerTest.kt @@ -0,0 +1,38 @@ +/* + * Léon - The URL Cleaner + * Copyright (C) 2024 Sven Jacobs + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.svenjacobs.app.leon.core.domain.sanitizer.salesforce + +import io.kotest.core.spec.style.WordSpec +import io.kotest.matchers.shouldBe + +class SalesforceParametersSanitizerTest : + WordSpec( + { + val sanitizer = SalesforceParametersSanitizer() + + "invoke" should { + + "remove sfmc_activityid parameter as per #302" { + sanitizer( + "https://www.geox.com/it-IT/uomo/scarpe/stivaletti/?sfmc_activityid=a5542c58-11be-4f33-8dd5-5e0ebeae30f2", + ) shouldBe "https://www.geox.com/it-IT/uomo/scarpe/stivaletti/" + } + } + }, + )