Remove new lines and rich-text formatting from subject field
This commit is contained in:
parent
1c1be7ff8e
commit
be67e849c2
4 changed files with 51 additions and 2 deletions
|
@ -74,6 +74,7 @@ import com.fsck.k9.helper.IdentityHelper;
|
|||
import com.fsck.k9.helper.MailTo;
|
||||
import com.fsck.k9.helper.ReplyToParser;
|
||||
import com.fsck.k9.helper.SimpleTextWatcher;
|
||||
import com.fsck.k9.helper.Utility;
|
||||
import com.fsck.k9.mail.Address;
|
||||
import com.fsck.k9.mail.Flag;
|
||||
import com.fsck.k9.mail.Message;
|
||||
|
@ -636,7 +637,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
|
|||
builder = SimpleMessageBuilder.newInstance();
|
||||
}
|
||||
|
||||
builder.setSubject(subjectView.getText().toString())
|
||||
builder.setSubject(Utility.stripNewLines(subjectView.getText().toString()))
|
||||
.setSentDate(new Date())
|
||||
.setHideTimeZone(K9.hideTimeZone())
|
||||
.setTo(recipientPresenter.getToAddresses())
|
||||
|
|
|
@ -397,6 +397,10 @@ public class Utility {
|
|||
}
|
||||
}
|
||||
|
||||
public static String stripNewLines(String multiLineString) {
|
||||
return multiLineString.replaceAll("[\\r\\n]", "");
|
||||
}
|
||||
|
||||
|
||||
private static final String IMG_SRC_REGEX = "(?is:<img[^>]+src\\s*=\\s*['\"]?([a-z]+)\\:)";
|
||||
private static final Pattern IMG_PATTERN = Pattern.compile(IMG_SRC_REGEX);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/message_compose_subject_hint"
|
||||
android:inputType="textEmailSubject|textAutoCorrect|textCapSentences|textImeMultiLine"
|
||||
android:inputType="textEmailSubject|textAutoCorrect|textCapSentences"
|
||||
android:imeOptions="actionNext"
|
||||
android:singleLine="true"
|
||||
android:background="@android:color/transparent"
|
||||
|
|
44
k9mail/src/test/java/com/fsck/k9/helper/UtilityTest.java
Normal file
44
k9mail/src/test/java/com/fsck/k9/helper/UtilityTest.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package com.fsck.k9.helper;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class UtilityTest {
|
||||
|
||||
@Test
|
||||
public void stripNewLines_removesLeadingCarriageReturns() {
|
||||
String result = Utility.stripNewLines("\r\rTest");
|
||||
|
||||
assertEquals("Test", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stripNewLines_removesLeadingLineFeeds() {
|
||||
String result = Utility.stripNewLines("\n\nTest\n\n");
|
||||
|
||||
assertEquals("Test", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stripNewLines_removesTrailingCarriageReturns() {
|
||||
String result = Utility.stripNewLines("Test\r\r");
|
||||
|
||||
assertEquals("Test", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stripNewLines_removesMidCarriageReturns() {
|
||||
String result = Utility.stripNewLines("Test\rTest");
|
||||
|
||||
assertEquals("TestTest", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stripNewLines_removesMidLineFeeds() {
|
||||
String result = Utility.stripNewLines("Test\nTest");
|
||||
|
||||
assertEquals("TestTest", result);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue