From 91425162f0d5f714cbfeeaac24979773675199e1 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Fri, 24 Jan 2025 16:55:54 +0530 Subject: [PATCH] domain sanitize so no special added --- lib/Service/DomainService.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Service/DomainService.php b/lib/Service/DomainService.php index eb62841..ad7b480 100644 --- a/lib/Service/DomainService.php +++ b/lib/Service/DomainService.php @@ -72,8 +72,17 @@ class DomainService { * Add a custom disposable domain to the list. */ public function addCustomDisposableDomain(string $domain, IL10N $l, array $relatedDomains = []): void { + // Sanitize the domain and related domains to remove control characters + $cleanDomain = preg_replace('/[\x00-\x1F\x7F]/', '', $domain); + $cleanRelatedDomains = array_map(fn ($relatedDomain) => preg_replace('/[\x00-\x1F\x7F]/', '', $relatedDomain), $relatedDomains); + + // Get existing domains from the file $domains = $this->getDomainsFromFile(self::DISPOSABLE_DOMAINS_FILE, $l); - $newDomains = array_unique(array_merge($domains, [$domain], $relatedDomains)); + + // Merge, deduplicate, and sanitize + $newDomains = array_unique(array_merge($domains, [$cleanDomain], $cleanRelatedDomains)); + + // Save the updated list to the file $this->saveDomainsToFile(self::DISPOSABLE_DOMAINS_FILE, $newDomains); } -- GitLab