GH-9620: Use Locale.ROOT for neutral, case insensitive comparisons

Fixes: #9620
Issue link: https://github.com/spring-projects/spring-integration/issues/9620

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
This commit is contained in:
Artem Bilan
2024-10-31 10:59:05 -04:00
parent ff2b295be8
commit 0d2595ef7c
7 changed files with 66 additions and 58 deletions

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.mail;
import java.time.Instant;
import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.ScheduledFuture;
@@ -79,7 +80,7 @@ public class ImapMailReceiver extends AbstractMailReceiver {
public ImapMailReceiver(String url) {
super(url);
if (url != null) {
Assert.isTrue(url.toLowerCase().startsWith(PROTOCOL),
Assert.isTrue(url.toLowerCase(Locale.ROOT).startsWith(PROTOCOL),
"URL must start with 'imap' for the IMAP Mail receiver.");
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.springframework.integration.mail.config;
import java.util.Locale;
import java.util.Properties;
import jakarta.mail.Authenticator;
@@ -162,8 +163,8 @@ public class MailReceiverFactoryBean extends AbstractFactoryBean<MailReceiver> {
private MailReceiver createReceiver() { // NOSONAR
verifyProtocol();
boolean isPop3 = this.protocol.toLowerCase().startsWith("pop3");
boolean isImap = this.protocol.toLowerCase().startsWith("imap");
boolean isPop3 = this.protocol.toLowerCase(Locale.ROOT).startsWith("pop3");
boolean isImap = this.protocol.toLowerCase(Locale.ROOT).startsWith("imap");
Assert.isTrue(isPop3 || isImap, "the store URI must begin with 'pop3' or 'imap'");
AbstractMailReceiver mailReceiver = isPop3
? new Pop3MailReceiver(this.storeUri)