diff options
author | Tony Mantler <nicoya@google.com> | 2014-06-06 13:31:56 -0700 |
---|---|---|
committer | Tony Mantler <nicoya@google.com> | 2014-06-06 13:53:43 -0700 |
commit | a58c73ef197c6c18510b6b311dd1aebc38cb2f01 (patch) | |
tree | 62adc69b35db9b7a1117ed9f25ba760354f2dfd4 /tests | |
parent | 3b2742ee456cc88f3445a6b906ef5d3d41badcb1 (diff) | |
download | android_packages_apps_UnifiedEmail-a58c73ef197c6c18510b6b311dd1aebc38cb2f01.tar.gz android_packages_apps_UnifiedEmail-a58c73ef197c6c18510b6b311dd1aebc38cb2f01.tar.bz2 android_packages_apps_UnifiedEmail-a58c73ef197c6c18510b6b311dd1aebc38cb2f01.zip |
Handle surrogate pairs in HTML->Plaintext conversion
Fixes sending emoji in plaintext emails
b/15194631
Change-Id: I85aca13ddb0a8ebc95cda692226394f2cddf54f0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/google/android/mail/common/base/StringUtilTest.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/src/com/google/android/mail/common/base/StringUtilTest.java b/tests/src/com/google/android/mail/common/base/StringUtilTest.java new file mode 100644 index 000000000..cbb54e2db --- /dev/null +++ b/tests/src/com/google/android/mail/common/base/StringUtilTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.android.mail.common.base; + +import android.test.suitebuilder.annotation.SmallTest; + +import junit.framework.TestCase; + +@SmallTest +public class StringUtilTest extends TestCase { + public void testUnescapeHtml() { + // Unicode Character 'KISSING CAT FACE WITH CLOSED EYES' (U+1F63D) + final String unescaped1 = StringUtil.unescapeHTML("😽"); + assertEquals(unescaped1, "\uD83D\uDE3D"); + + // Unicode Character 'KISSING CAT FACE WITH CLOSED EYES' (U+1F63D) + final String unescaped2 = StringUtil.unescapeHTML("😽"); + assertEquals(unescaped2, "\uD83D\uDE3D"); + + // Unpaired surrogate, should not be converted + final String unescaped3 = StringUtil.unescapeHTML("&#D83D;"); + assertEquals(unescaped3, "&#D83D;"); + + // Paired surrogate, also should not be converted according to HTML spec + final String unescaped4 = StringUtil.unescapeHTML("&#D83D;&#DE3D;"); + assertEquals(unescaped4, "&#D83D;&#DE3D;"); + + // Named entity lowercase + final String unescaped5 = StringUtil.unescapeHTML("α"); + assertEquals(unescaped5, "\u03B1"); + + // Named entity uppercase + final String unescaped6 = StringUtil.unescapeHTML("Α"); + assertEquals(unescaped6, "\u0391"); + } +} |