views:

52

answers:

2

Hello,

I'm currently writing an iPhone application which gets some data from the user and uploads it to a server. The uploaded data will be displayed to other users of the same program (there's more to it than that, but to keep the idea simple...). The data which is uploaded is basically just three strings: a name(max. 50 char.), a title(max. 50 char.) and some text(virtually unlimited char.). What I need is basically a function, service or algorithm which can detect how valid the data input is. It would have to be able to detect series of repetitive characters, certain 'illegal' words, abnormal whitespaces, etc. So my questions is; is there a C or Objective-C library (build-in or open source) for this sort of data validation, or else, how would I go about doing this kind of check?

Here are two examples of good and bad data:

GOOD:

Name: "John Aaron Smith"  
Title: "Why am I still here?"  
Text: "Can anybody please help me? I'm feeling lonely!"

BAD:

Name: "f**k you, kldsanfklds"   
Title: "Only $99. Buy Now. Only $99"  
Text: "ndsaklgnvds lakævndsaklæfhadsæhdsjka fhdskjafhdskj lafhsdkhf. €#&/ #&()(/&%& ># €%€#% €#& hidosæahviædshvidshfiodsa. adsifjDSILFJIDSH \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"

I know taking precautions for so many cases will be difficult, but this algorithm/library would just have to filter the worst spam. I will also be looking through the data before the final database submission, but of course the less spam, the easier I'll have it.

Yours, BEN.

EDIT: My most 'fluent' language is objective-C, but I'm also doing pretty well with C, and I have knowledge of PHP and JAVA. Libraries/examples in other languages might be difficult for me to understand, and 'translate' into a valid iPhone language.

EDIT-EDIT: I'm not looking for something overly sophisticated. Just a simple way for me to do the rough cut.

+1  A: 

This is a very difficult problem to solve. I would not attempt to create my own spam detection, I would use a solution which already exists and has a good reputation, such as SpamAssassin.

Ben S
For a free service, can he get that for free? If I were running a free service, I'd be willing to donate computer time and bandwidth, but paying a third party to prevent vandalism would get to me.
David Thornley
I'd also look at Akismet - which has worked pretty well for me in the past. Same consideration though for commercial licensing.
paulthenerd
Akismet looks pretty cool. I'd have to port one of the implementations to C(which might take quite a while), but else it could be usable considering I probably won't make $500 a month.
Benjamin Egelund-Müller
A: 

Have you seen Mollom? It has a bunch of developer libraries (php, ruby, perl, etc) that communicate with the Mollom servers to determine the spaminess of an entry. It wouldn't be hard to translate one of those to Objective-C.

Dave DeLong
Mollom looks interresting, but it is also quite expensive considering that I'm a hobbiest looking to release a free application.
Benjamin Egelund-Müller