More in this section
Blogs RSS feed

Removing Obscenities from Your Content

by Peter Filipov

When many people are publishing content on a website, it leads to variety of opinions which is always good. But working with a large content team also brings complexity, like inconsistencies in the general understanding of what is appropriate for your audience and what is a harsh tone. With that in mind, we should avoid publishing offensive content at any cost. Keep in mind that sometimes the standard autocorrect creates more problems than it solves. With Sitefinity 10.1 you have the option to sanitize your content easily and remove any obscene words, such as those we can only refer to here by their first letter – let’s call them collectively the “X-word“.


How to sanitize your content?

With Sitefinity 10.1 you can create your own DataSanitizeProcessor and check all the content that is going into your Database. You need to inherit the ProcessorBase class and implement the IDataProcessor interface. The data processor is activated for each content type and its fields. If you want to apply a check to a field, return true in the ShouldProcess method. Here is a sample illustrating the idea:

using System;
using System.Collections.Specialized;
using System.ComponentModel;
using Telerik.Sitefinity.Data.DataProcessing.Processors;
using Telerik.Sitefinity.News.Model;
using Telerik.Sitefinity.Processors;
namespace SitefinityWebApp
    public class DataSanitizer : ProcessorBase, IDataProcessor
        public virtual void Process(ref object value)
            if (value != null && value is string)
                value = ((string)value).Replace("X-word", "CENSORED");
        public virtual bool ShouldProcess(PropertyDescriptor prop, Type type)
            if (type == typeof(NewsItem) && (prop.Name == "Content" || prop.Name == "Title"))
                return true;
            return false;
        protected override void Initialize(NameValueCollection config)


Handling offensive comments

When it comes to comments, the approach is different since the input comes from the directly from the frontend of the website. To deal with inappropriate comments and censor them you only need to override one method in comments.js. The JS file tells the client-side how to visualize the comments. To get the current implementation of the file, open Telerik.Sitefinity.Frontend.Comments.dll with JustDecompile and look in the resources folder for Telerik.Sitefinity.Frontend.Comments.MVC.Scripts.comments-list.js.

Copy the content into a new comments-list.js file and put it in the MVC folder under the Bootstrap resource package. 

The last step is to change the implementation of the attachCommentMessage function. E.g.:

            Comments listing
        attachCommentMessage: function (element, message) {
            if (element && message) {
                message = message.replace("X-word", "CENSORED");
                var rawText = message.replace(/<[^>]*>/ig, ' ');
                if (rawText.length < this.settings.commentsTextMaxLength) {
                else {
                    element.append($('<p data-sf-role="comments-read-substr-comment-header" />').html(rawText.substr(0, this.settings.commentsTextMaxLength)));
                    element.append($('<span />').hide().html(message));
                    element.append($('<a href="#" data-sf-role="comments-read-full-comment-button" />').text(this.settings.useReviews ? this.resources.readFullReview : this.resources.readFullComment));

To avoid discrepancies after upgrading, the best practice is to get the latest version of the JS file and merge it with your version.


Code implementation or a swear jar

Even if you apply a basic replacement mechanism to handle the obscene words, the experience on your website will greatly benefit from it. If you don’t want to use this word sanitizer, you can always consider putting a jar in your office and collecting $1 for each bad word instead :). 


Leave a comment
  1. sabir Apr 11, 2018
    We could get the youtube proxy site online when we can generate the proxy for youtube online.
  2. Albina Apr 24, 2018
    Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success
  3. Zoya120 Jun 02, 2018
    I am happy to be here and this wonderful article. I have found here lots of interesting information for my knowledge I need. all the details you provide to us, it was very helpful and useful, thanks for sharing this amazing post.
    Lexmark Support Number
  4. health care safes Jun 07, 2018
  5. robert Jun 08, 2018
    This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post.! corporate video
  6. robert Jun 08, 2018
    You have a good point here!I totally agree with what you have said!!Thanks for sharing your views...hope more people will read this article!!!franklin tn real estate agents
  7. robert Jun 08, 2018
    I found your this post while searching for information about blog-related research ... It's a good post .. keep posting and updating information.surfcamp niños tarifa
  8. robert Jun 08, 2018
    Nice to be visiting your blog again, it has been months for me. Well this article that i’ve been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.franklin tn real estate agents
  9. robert Jun 08, 2018
    This is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works.Breast Augmentation
  10. robert Jun 08, 2018
    Thanks for your post. I’ve been thinking about writing a very comparable post over the last couple of weeks, I’ll probably keep it short and sweet and link  to this instead if thats cool. Thanks.ccna weekend courses london
  11. robert Jun 08, 2018
    If more people that write articles really concerned themselves with writing great content like you, more readers would be interested in their writings.  Thank you for caring about your content.mcsa training london
  12. GoDaddy $1 Hosting Jun 08, 2018
    Very good written article. It will be supportive to anyone who utilizes it, including me. Keep doing what you are doing – can’r wait to read more posts.GoDaddy $1 Hosting
  13. fortnite boosting Jun 20, 2018
    thanks for this usefull article, waiting for this article like this again.fortnite boosting
  14. game Jun 23, 2018
    the game thanks
  15. jone Jun 26, 2018
    I am very enjoyed for this blog. Its an informative topic. It help me very much to solve some problems. Its opportunity are so fantastic and working style so Scottsdale
  16. jone Jul 04, 2018
    This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free.DETECTIVES MADRID
  17. detective Jul 17, 2018
    Thanks for this article very helpful. thanks.detectives Madrid
  18. jone Jul 18, 2018
    Wow! This could be one of the most useful blogs we have ever come across on thesubject. Actually excellent info! I’m also an expert in this topic so I can understand your effort.Rogaine for men
  19. Lizette Jul 22, 2018
    However the fact is that acquisition of the loan are quite easy processes without requiring lengthy documents from the borrowers.. No matter what your requirement is, with unsecured personal loans, you can now manage to arrange money to solve any of your purposes.. It means that the borrower has to provide any piece of asset having considerable equity worth to qualify for the loan.. zoca loans direct lender short term loans | zoca loans fast loans no credit check | zoca loans direct payday lenders online only | zoca loans no credit check personal loans direct lenders | zoca loans payday loans no credit check direct lenders
  20. kakbrus Jul 23, 2018

    Thank you for posting such a great article! I found your website perfect for my needs. It contains wonderful and helpful posts. Keep up the good work!. five nights at freddy's

    Leave a comment