Android Question Is it worthwhile to check for swear words in user names?

Diceman

Active Member
Licensed User
I am writing an Android app where the user authenticates to a B4J server using UserName, Password.
1) Should I allow the user to create any user name he likes?
2)Or should the server reject any user name with swear words in it?

If #2, then I will need to write a sub to search for these swear words. Since I'm already using a database I thought I would create a record with a memo field to store all swear words. Then when the user registers the user name, the B4J server would parse out these swear words and see if they are in the UserName. If it is, then it would examine the adjacent characters to determine if the word is by itself. If it is, then the UserName is rejected and the user is forced to enter a different UserName.

I'm wondering if this is the best way to handle it. Or am I worrying about nothing?

TIA
 

AHilton

Active Member
Licensed User
Longtime User
In general, if you don't have a great need for it, do #1. It looks like an easy problem to solve but it can become mind-bendingly difficult. Much like blacklisting things, it's just an exercise in futility trying to tweak so that you catch every single one … and then, trying to make it quick.

With that said, if you really must do #2, then don't fall into the trap of thinking you can get it perfect and fast. You can't. It's a coding rabbit hole.

I created a registration / authentication server from B4J that most of my projects use now. It serves many clients' (and all of their users) apps as well as my own. One configuration setting for each client app is to do exactly #2. Having done this sort of thing many years ago, I thought I'd see where I and technology advances could finally make this work ideally. I'll have to wait a bit more, I suppose for A.I., quantum computers, and inspiration from the coding vespers before trying again.

The route I took on this latest B4J server (and it does work very well, mind you, but it isn't positively perfect AND fast), was to put the 'bad words' into records of an SQL table and read those into memory (a B4x list). Why memory instead of doing a SQL search? Because at last count there's only 167 words/records. Obviously, if you have a huge number of words, you'd want to rethink that. Although, you'll quickly run into speed problems (because that's a path I went down, too).

So, you've now got a list of 'bad words'. I compare each item in that list with the user name in a regular expression regex. You're right that you'll need to handle embedded 'bad words' and whether or not to reject just because a username may be "Muscuntly" or "TailsHit" or "Mash it" (the AOL Scunthorpe problem). Remember punctuation, too. For a small list, it's pretty fast. It quickly goes downhill at a certain point (ie supporting multiple languages … I have a configuration option for that, too, in order to limit that in-memory list). We've found that a more complex regex is fastest as compared to running multiple regex's. But, there's a limit to that, too, as it can become cumbersome and unwieldy.

Then, you have the human factor … Once you start filtering like that, your users will expect it to be perfect AND flexible. You'll never please them. You could spend more time tweaking (we did!!!) it than you want and it still won't be perfect.

The overarching suggestion from me is this: Do it if you must, but don't be surprised if you wished you never went there in the first place.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Absolutely not, just let the users use whatever name they like.

First of all, you can't win this one, once they realize there's a filter you'll see that there's no limit to human creativity on how to get past it.

Lastly, there are a surprising number of real names with swear parts in them, and you would stop them from using their names.

So focus your energy on something else, is my recommendation.
 
Last edited:
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
just show a rule that bad words are not desired. some kind of regulation.
 
Upvote 0

Diceman

Active Member
Licensed User
The reason I wrote this thread is in case kids use the application and people are using swear words as user names (or in their comments), then Google Store may restrict the application to "adults only" or pull the app from Google Store entirely. Apple tried to do this years ago with a dictionary app but they got a lot of backlash from the public and relented. https://www.theregister.co.uk/2009/08/06/apple_denies_dictionary_censorship/

I will definitely add Markus's suggestion to the app and to the EULA. I will add the capability to manually suspend an account until the user changes the user name. This is necessary because as many of you know, it seems that we need to be "politically correct" and not offend people otherwise we could lose the right to sell our app or be sued by someone who was offended, even though it wasn't our fault to begin with.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
maybe make a name generator so the user name are always ok
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…