Merge "VCARD allow mime data"
diff --git a/java/com/android/vcard/VCardParserImpl_V21.java b/java/com/android/vcard/VCardParserImpl_V21.java
index e8655a8..2fa52df 100644
--- a/java/com/android/vcard/VCardParserImpl_V21.java
+++ b/java/com/android/vcard/VCardParserImpl_V21.java
@@ -216,7 +216,8 @@
         mCurrentEncoding = DEFAULT_ENCODING;
         mCurrentCharset = DEFAULT_CHARSET;
 
-        boolean allowGarbage = false;
+        // allow parsing of vcards that have mime data leading up to BEGIN:VCARD
+        boolean allowGarbage = true;
         if (!readBeginVCard(allowGarbage)) {
             return false;
         }
diff --git a/tests/res/raw/v21_nest_with_mime.vcf b/tests/res/raw/v21_nest_with_mime.vcf
new file mode 100644
index 0000000..e850821
--- /dev/null
+++ b/tests/res/raw/v21_nest_with_mime.vcf
@@ -0,0 +1,16 @@
+Content-Type: text/x-vcard
+CHARSET=utf-8
+profile=vCard
+BEGIN:VCARD
+VERSION:2.1
+N:parent
+BEGIN:VCARD
+VERSION:2.1
+N:nest1
+END:VCARD
+BEGIN:VCARD
+VERSION:2.1
+N:nest2
+END:VCARD
+TEL:1
+END:VCARD
diff --git a/tests/src/com/android/vcard/tests/VCardImporterNestTests.java b/tests/src/com/android/vcard/tests/VCardImporterNestTests.java
index f4b04e8..0a36e05 100644
--- a/tests/src/com/android/vcard/tests/VCardImporterNestTests.java
+++ b/tests/src/com/android/vcard/tests/VCardImporterNestTests.java
@@ -32,4 +32,16 @@
                 .addExpectedNodeWithOrder("N", "parent")
                 .addExpectedNodeWithOrder("TEL", "1");
     }
+
+    public void testSimpleNestWithMime() {
+        mVerifier.initForImportTest(V21, R.raw.v21_nest_with_mime);
+        mVerifier.addPropertyNodesVerifierElem()
+                .addExpectedNodeWithOrder("N", "nest1");
+        mVerifier.addPropertyNodesVerifierElem()
+                .addExpectedNodeWithOrder("N", "nest2");
+        // Parent comes last.
+        mVerifier.addPropertyNodesVerifierElem()
+                .addExpectedNodeWithOrder("N", "parent")
+                .addExpectedNodeWithOrder("TEL", "1");
+    }
 }