Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForumA slight improvement over the old Bad Word filterA slight improvement over the old Bad Word filter
Previous
 
Next
New Post
9/18/2007 11:11 AM
 

We came across an issue where the bad word filter is replacing text that should not be.  For example the word "passage" will come back "pfannyage".  While working on this I came across two issues applying regular expressions: 1. Sureptitious badwords using numbers and special characters and 2. replacing the text more precisely. For example when doing a replace, you do not want to do a replace on white space which could concatenate two words. "This is a badword to see" might become This is afannyto see.

I do not know the status of the new bad word filter, but the following is a start (no time to perfect it) .  Any improvement that could be made to this, would be really appreciated here.  So here are the changes I made to the ForumWordFilterController class.  Actually, it is only the relevant code:

This is only a start!  But we need a "really good" bad word filter and maybe contributions to this thread could help us all:

at the top of the page:  Private Const RegexMetaCharacters As String = "(\[|\\|\^|\$|\.|\||\?|\*|\+|\(|\))"

in the functions where the work is done:

'
                        '***************************************************************
                        '09-17-07 improvement to bad word filter via regular expressions
                        'for more precision - jfs.

                        Dim filter As StringBuilder
                        Dim exp As String = String.Empty
                        Dim wordCapture As String = String.Empty
                        Dim rx As Regex = Nothing

                        If (Regex.IsMatch(objFilterWord.BadWord, RegexMetaCharacters)) Then
                            wordCapture = Regex.Escape(objFilterWord.BadWord)
                        Else
                            wordCapture = objFilterWord.BadWord
                        End If

                        '(?i)(\b(\d?|_?)*a\$\$(\d?|_?)*)
                        filter = New StringBuilder(30)
                        filter.Append("(?i)(\b(\d?|_?)*")
                        filter.Append(wordCapture)
                        filter.Append("(\d?|_?)*)")
                        exp = filter.ToString().Trim()
                        '
                        rx = New Regex(exp)
                        '
                        If (rx.IsMatch(Text)) Then
                            Text = rx.Replace(Text, objFilterWord.ReplacedWord)
                        End If

I have not "thoroughly" tested this, but it will capture

a$$ A$$ 59a$$777 &quote;a$$&  "A$$" 'a$$' _a$$,  a$$ followed by "_", but not the "_" itself

But not pa$$age

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForumA slight improvement over the old Bad Word filterA slight improvement over the old Bad Word filter


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out