/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/importcontacts/VcardImporter.java

  • Committer: edam
  • Date: 2012-12-30 17:17:51 UTC
  • Revision ID: tim@ed.am-20121230171751-8ni3r9bf7pqpa2ng
less strict parsing of vcard begin/end lines and version numbers

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
                        {
136
136
                                if( !in_vcard ) {
137
137
                                        // look for vcard beginning
138
 
                                        if( line.matches( "^BEGIN:VCARD" ) ) {
 
138
                                        if( line.matches( "^BEGIN[ \t]*:[ \t]*VCARD.*$" ) ) {
139
139
                                                in_vcard = true;
140
140
                                                _vcard_count++;
141
141
                                        }
142
142
                                }
143
 
                                else if( line.matches( "^END:VCARD" ) )
 
143
                                else if( line.matches( "^END[ \t]*:[ \t]*VCARD.*$" ) )
144
144
                                        in_vcard = false;
145
145
                        }
146
146
 
203
203
 
204
204
                        if( vcard == null ) {
205
205
                                // look for vcard beginning
206
 
                                if( line.matches( "^BEGIN[ \t]*:[ \t]*VCARD" ) ) {
 
206
                                if( line.matches( "^BEGIN[ \t]*:[ \t]*VCARD.*$" ) ) {
207
207
                                        setProgress( _progress++ );
208
208
                                        vcard = new Vcard();
209
209
                                        vcard_start_line = cli.getLineNumber();
211
211
                        }
212
212
                        else {
213
213
                                // look for vcard content or ending
214
 
                                if( line.matches( "^END[ \t]*:[ \t]*VCARD" ) )
 
214
                                if( line.matches( "^END[ \t]*:[ \t]*VCARD.*$" ) )
215
215
                                {
216
216
                                        // finalise the vcard/contact
217
217
                                        try {
478
478
 
479
479
                private String extractNameAndParamsFromLine( ContentLine content_line )
480
480
                {
481
 
                        return extractCollonPartFromLine( content_line, true );
 
481
                        return extractCollonPartFromLine( content_line, true ).trim();
482
482
                }
483
483
 
484
484
                private String extractValueFromLine( ContentLine content_line )
502
502
                                        name_and_params.equalsIgnoreCase( "VERSION" ) )
503
503
                                {
504
504
                                        // yes, get it!
505
 
                                        String value = extractValueFromLine( content_line );
 
505
                                        String value = extractValueFromLine( content_line ).trim();
506
506
                                        if( !value.equals( "2.1" ) && !value.equals( "3.0" ) )
507
507
                                                throw new ParseException( R.string.error_vcf_version );
508
508
                                        _version = value;