bowdlerize_text

one of the documented procedures in this installation of the ACS
Usage:
bowdlerize_text   text
What it does:
Returns bowdlerized version of TEXT or empty string if no bowdlerization was necessary
Defined in: /web/philip/tcl/ad-content-tagging.tcl

Source code:


    ns_share tag_array
    set user_id [ad_get_user_id]    

    set timeout [ad_parameter CacheTimeout content-tagging]

    set bowdlerization_level [util_memoize "bowdlerization_level"]
    set naughty_words [util_memoize "naughty_words_for_level $bowdlerization_level" $timeout]

    if { [empty_string_p $naughty_words] } {
	# publisher hasn't defined any naughty words at this level
	return ""
    }

    set replacement_text [ad_parameter BowdlerizationText content-tagging]

    # Solely naughty words.
    set bowdler_re1 "^($naughty_words)\$"
    set bowdler_replace_str1 $replacement_text

    # Embedded naughty words.
    set bowdler_re2 "(\[^A-Za-z0-9\])($naughty_words)(\[^A-Za-z0-9\])"
    set bowdler_replace_str2 "\\1$replacement_text\\3"
    
    # Naughty words at the beginning.
    set bowdler_re3 "^($naughty_words)(\[^A-Za-z0-9\])"
    set bowdler_replace_str3 "$replacement_text\\2"
    
    # Naughty words at the end.
    set bowdler_re4 "(\[^A-Za-z0-9\])($naughty_words)\$"
    set bowdler_replace_str4 "\\1$replacement_text"

    
    if { [regsub -all -nocase $bowdler_re1 $text $bowdler_replace_str1 text] 
	 + [regsub -all -nocase $bowdler_re2 $text $bowdler_replace_str2 text] 
	 + [regsub -all -nocase $bowdler_re3 $text $bowdler_replace_str3 text] 
	 + [regsub -all -nocase $bowdler_re4 $text $bowdler_replace_str4 text] } {
	return $text
    } else {
	return ""
    }


philg@mit.edu