Giter Club home page Giter Club logo

mixerp.net.vcards's People

Contributors

binodnp avatar cymptom avatar dgwaldo avatar zoh48gz04 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mixerp.net.vcards's Issues

VCards aren't able to handle multiple types on Telephone

Other libraries allow you to do something like this...

            var phoneFax = new vCard.vTelephone();
            phoneFax.Location = vCard.vLocations.WORK;
            phoneFax.Type = vCard.vPhoneTypes.FAX;
            phoneFax.TelephoneNumber = contact.FaxNumber;
            vc.Telephones.Add(phoneFax);

Producing output like TEL;WORK;FAX:555-555-5555

This library doesn't allow for that without doing something custom...

Address type shows Domestic for all addresses

When importing a VCF made by Outlook (2.1), it will deserialize the home and work addresses both as Domestic type.
IE vcf data:
ADR;WORK;PREF:;;Stadhuislaan 1;Rotterdam;Zuid-Holland;3000RT;Netherlands
ADR;HOME:;;Seringenstraat 1001;Ridderkerk;Zuid-Holland;2982BV;Nederland

Multiple vcards in single file or string not properly separated

The call to VCardHelper.SplitCards() not only failed for my initial test with multiple vcards in one file, but looking at the regex call, it is completely ineffective. Not only does it look like Regex.Split() is misunderstood, but the regular expression itself --using default options-- will not match any vcard. First of all, the Split function expects a pattern to match delimiters, not the full expression. Next, the default interpretation of the period (.) operator is all characters except \n. So immediately the pattern should fail to match any vcard with line breaks. But even if it did match line breaks, the * is by default greedy and will continue to match every character until the very last "END:VCARD", so it would still not separate multiple vcards.

I have already crafted a valid regex and can submit a change, but I'm completely new to contributing on github and also want to get feedback, since I would be surprised if absolutely nobody has tried importing a multi-vcard file or string.

Unable to install the library

I am currently working on a Windows Phone 8.1 app.
When I try to install the library it gives me the following error code:

Severity Code Description Project File Line Suppression State
Error Could not install package 'MixERP.Net.VCards 1.0.7'. You are trying to install this package into a project that targets 'WindowsPhoneApp,Version=v8.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0

Can I change the target?
Can anyone help me to resolve this issue I'm new to .NET

Check input validity

Hi there,

thanks for your great lib first!

I'm parsing uploaded files as vCards so that I can import them in my DB.
This works pretty nice, almost a little bit too nice:
If the input in "MixERP.Net.VCards.Deserializer.GetVCards()" is not a valid vCard, I (sometimes) also get back an empty vCard.
I Tried this with the following "vCard":

OUGEGlnvdog
rwz
53zu
hh4
5ehtde
§%
4
6&

Is there some validation method to use I overlooked?
Thanks in advance!

Dont work

System.ArgumentException: An item with the same key has already been added. Key: TYPE
at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at MixERP.Net.VCards.Parser.TokenParser.GetAdditionalKeyMembers(String data) at MixERP.Net.VCards.Parser.TokenParser.GetToken(String line) at MixERP.Net.VCards.Parser.TokenParser.Parse(String contents) at MixERP.Net.VCards.Deserializer.GetVCard(String contents) at System.Linq.Enumerable.SelectArrayIterator2.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at MixERP.Net.VCards.Deserializer.GetVCards(String contents)

City

Hi there,
I really like this little awesome library! However, I can't set the city on the Address Type, how is this supposed to work?

Photo.Contents field value incorrect

The Photo.Contents field in the vCard only contains the first line of the Base64 string, and not the entire value. Ideally the whole string would be concatenated together or better yet, provided as an actual .NET Image rather than the original string value.

Folded fields don't work

Field with values folded on multiple lines are not parsed correctly (see Folded in https://tools.ietf.org/html/rfc6350)

For example, when I have a long field NOTE, it is folded on multiple lines to avoid lines longer than 75 chars:

NOTE:Lorem ipsum dolor sit amet\, consectetur adipiscing elit\, sed do eius
 mod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim v
 eniam\, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea co
 mmodo consequat.

But it is not loaded correctly.

I have fixed that in my fork https://github.com/exyi/MixERP.Net.VCards/, so you can take it. I'm not sending a PR, since I have made few more changes to make it build in my project and I don't want to pollute your repo with that.

German special characters

Hi,

my cards contain german special characters. The file itsself contains the correct characters, but when I open them via Outlook the characters are not displayed correctly. I manualy added the following to the file: N;CHARSET=utf-8. This makes the characters show correctly. How can I add this programatically?

regards Mario

Question: Which encoding does the parser consider?

Hi,

I am quite new to VCards, so probably I got it all wrong...
I scimmed the code but did not see any encoding consideration.

In VCard (2.1?) there is this notion of inline-encoding like "FN;CHARSET=UTF-8:üüü".
Do you support that style?

According to https://android.stackexchange.com/questions/106888/what-vcard-formats-versions-and-encodings-are-supported-for-import, the versions are different in their regard of default encodings.
Though, the information collides a bit against https://de.wikipedia.org/wiki/VCard.

As this project seems to be live, I am considering it for parsing/changing the vcard address book of Becky! Internet Mail from outside. However, I would like to be as international as Becky! is having both Japanese and Western European users, and I am stuck with Becky! libraries' ableness for VCards.
In manual tests I got Becky read in the UTF-8 inline correctly (for FN) while Becky is using ISO or win 1252 per default for new entries. As said, I need to support both.

Luckily, currently I only want to add new VCard entries into the file and parse the email out of it, so a no-framework-approach would work as well. But, of course, I need to read quite deeply about folding and such.

MFG

System.ArgumentException: An item with the same key has already been added.

Test method TestsUnitarios.TestsVCF.Leer_Vcard_Contactos threw exception:
System.ArgumentException: An item with the same key has already been added.

Don't work: TEL;TYPE=WORK;TYPE=PREF:6xx-xxx-xxx

Work: TEL;TYPE=CELL:6xx-xxx-xxx

Test Name: Leer_Vcard_Contactos
Test Outcome: Failed
Result StackTrace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at MixERP.Net.VCards.Parser.TokenParser.GetAdditionalKeyMembers(String data) at MixERP.Net.VCards.Parser.TokenParser.GetToken(String line) at MixERP.Net.VCards.Parser.TokenParser.Parse(String contents) at MixERP.Net.VCards.Deserializer.GetVCard(String contents) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at MixERP.Net.VCards.Deserializer.GetVCards(String contents)
at TestsUnitarios.TestsVCF.Leer_Vcard_Contactos() in
\GMailManager\Tests\TestsUnitarios\TestsVCF.cs:line 37
Result Message:

System.ArgumentException: An item with the same key has already been added.

Logic of parsing values with commas is flawed

The way the code is written makes it impossible to preserve commas in comma-separated lists.

For instance, if we have this:

 CATEGORIES:Home\,Sport,Group

After parsing we should have two categories: "Home,Sport" and "Group". But we end up with three: "Home", "Sport", "Group". And the code is written the way which makes it hardly possible to quick-fix this. The code first eliminates escaping in tokenizer (so that you'll have "Home,Sport,Group" down the code) and then splits it by individual tokens and so on.

It does not make any difference between tokens which are just text and which are comma-separated lists (like CATEGORIES). So, "\," and "," become equivalent after Sanitizer.UnEscape processing.

Error: An item with the same key has already been added. Key: TYPE

Loaded the library tonight to parse a .vcf file. Tried multiple files, and this is the error I received.

An item with the same key has already been added. Key: TYPE

Here is the code generating the error. The .vcard file download is from google contacts.

```
public IEnumerable<Contact> GetContacts(Stream stream) {
		var reader = new StreamReader(stream, encoding: Encoding.UTF8);
		string contents = reader.ReadToEnd();
		IEnumerable<VCard> vCards = MixERP.Net.VCards.Deserializer.GetVCards(contents);

		var contacts = new List<Contact>();
		foreach (var vcard in vCards) {
			contacts.Add(MapVCardToContact(vcard));
		}
		return contacts;
	}

	private Contact MapVCardToContact(VCard card) {
		var contact = new Contact {
			FirstName = card.FirstName,
			LastName = card.LastName,
			Company = card.Organization,
			JobTitle = card.Title,
			Note = card.Note
		};

		foreach (var f in card.Telephones) {
			contact.PhoneNumbers.Add(new PhoneNumber {
				DialNumber = f.Number,
				Label = f.Type.ToString()
			});
		}

		foreach (var e in card.Emails) {
			contact.EmailAddresses.Add(new EmailAddress {
				Email = e.EmailAddress,
				Label = e.Type.ToString()
			});
		}

		foreach (var a in card.Addresses) {
			contact.Addresses.Add(new Address {
				PostalCode = a.PostalCode,
				City = a.Locality,
				Region = a.Region,
				Street1 = a.Street,
				Street2 = a.PoBox,
				Label = a.Type.ToString()
			});
		}

		return contact;
	}

I loaded up the library in the debugger. It looks like the regex helper to split cards is the actual issue, looks like maybe an issue with the input data stream.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.