diff options
author | Marc Blank <mblank@google.com> | 2011-09-20 15:17:08 -0700 |
---|---|---|
committer | Marc Blank <mblank@google.com> | 2011-09-21 11:03:04 -0700 |
commit | 5870214d6c4991dd0a863bcd097860ddd896cab6 (patch) | |
tree | c79f459c3d7dad9402a8304930ee38a1a7d8e4af /tests/src | |
parent | a552c03ddc12121e59d1fb88138d34290b032077 (diff) | |
download | android_packages_apps_Exchange-5870214d6c4991dd0a863bcd097860ddd896cab6.tar.gz android_packages_apps_Exchange-5870214d6c4991dd0a863bcd097860ddd896cab6.tar.bz2 android_packages_apps_Exchange-5870214d6c4991dd0a863bcd097860ddd896cab6.zip |
Remove illegal characters from EAS 2.5 attachment file names
* For some reason, EAS 2.5 sends us partially encoded file names,
which we use to specify attachments to be loaded.
* It turns out that these file names aren't properly encoded for
EAS's use in the GetAttachment command; some additional characters
must be escaped using %nn.
* We now check for EAS 2.5 and escape illegal characters
Bug: 5341416
Change-Id: Ie112359e139581c8ae31e40869b2fa0e568d7f65
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/exchange/adapter/AttachmentLoaderTests.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/src/com/android/exchange/adapter/AttachmentLoaderTests.java b/tests/src/com/android/exchange/adapter/AttachmentLoaderTests.java new file mode 100644 index 00000000..2e16ac82 --- /dev/null +++ b/tests/src/com/android/exchange/adapter/AttachmentLoaderTests.java @@ -0,0 +1,40 @@ +/* Copyright (C) 2011 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. + */ + +/** + * You can run this entire test case with: + * runtest -c com.android.exchange.adapter.AttachmentLoaderTests exchange + */ +package com.android.exchange.adapter; + +import android.test.AndroidTestCase; +import android.test.suitebuilder.annotation.SmallTest; + +@SmallTest +public class AttachmentLoaderTests extends AndroidTestCase { + private static final String TEST_LOCATION = + "Inbox/FW:%204G%20Netbook%20|%20Now%20Available%20for%20Order.EML/image012.jpg"; + + public void testEncodeForExchange2003() { + assertEquals("abc", AttachmentLoader.encodeForExchange2003("abc")); + // We don't encode the four characters after abc + assertEquals("abc_:/.", AttachmentLoader.encodeForExchange2003("abc_:/.")); + // We don't re-encode escaped characters + assertEquals("%20%33", AttachmentLoader.encodeForExchange2003("%20%33")); + // Test with the location that failed in use + assertEquals(TEST_LOCATION.replace("|", "%7C"), + AttachmentLoader.encodeForExchange2003(TEST_LOCATION)); + } +} |