@@ -24,7 +24,7 @@ var Beep = {
2424
2525 parseContent : function ( content ) {
2626 var nil = '^(?!x)x' ;
27- return parseContent ( content , Beep . banned_words || nil , Beep . banned_urls || nil , Beep . censorWholeWord ) ;
27+ return parseContent ( content , Beep . banned_words || nil , Beep . banned_urls || nil , Beep . censorWholeWord || nil ) ;
2828 } ,
2929 toRegExp : toRegExp ,
3030 loadList : function ( callback ) {
@@ -34,27 +34,21 @@ var Beep = {
3434 return callback ( err ) ;
3535 }
3636
37- Beep . illegal_words = Beep . toRegExp ( hash . illegal , true ) ;
37+ Beep . illegal_words = new RegExp ( '\\b(?:' + Beep . toRegExp ( hash . illegal ) + ')\\b' , 'ig' ) ;
3838
3939 if ( hash . id && hash . id . length ) {
4040 var words = hash . id . split ( ',' ) . filter ( function ( word ) {
4141 return ! Beep . illegal_words . test ( word ) ;
4242 } ) ;
43- Beep . banned_words = Beep . toRegExp ( words , true ) ;
43+ Beep . banned_words = new RegExp ( '\\b(?:' + Beep . toRegExp ( words ) + ')\\b' , 'ig' ) ;
4444 Beep . banned_words_raw = hash . id ;
4545 } else {
46- Beep . banned_words = Beep . toRegExp ( defaultBanList , true ) ;
46+ Beep . banned_words = new RegExp ( '\\b(?:' + Beep . toRegExp ( defaultBanList ) + ')\\b' , 'ig' ) ;
4747 Beep . banned_words_raw = defaultBanList . join ( ',' ) ;
4848 winston . info ( 'Default list of Banned Words is enabled. Please go to administration panel to change the list.' ) ;
4949 }
50-
51- Beep . banned_urls = Beep . toRegExp ( hash . urls ) ;
52-
50+ Beep . banned_urls = new RegExp ( Beep . toRegExp ( hash . urls ) , 'ig' ) ;
5351 Beep . censorWholeWord = hash . censorWholeWord === 'on' ;
54- if ( meta . config ) {
55- meta . config . beep = meta . config . beep || { } ;
56- meta . config . beep . censorWholeWord = Beep . censorWholeWord ;
57- }
5852
5953 callback ( ) ;
6054 } ) ;
@@ -147,6 +141,26 @@ var Beep = {
147141 callback ( null , custom_header ) ;
148142 }
149143 } ,
144+ category : {
145+ get : function ( data , callback ) {
146+ var topics = data . category . topics ;
147+ topics . forEach ( function ( topic ) {
148+ topic . title = Beep . parseContent ( topic . title ) ;
149+ topic . slug = Beep . parseContent ( topic . slug ) ;
150+ } ) ;
151+ callback ( null , data ) ;
152+ } ,
153+ topics : {
154+ get : function ( data , callback ) {
155+ data . topics . forEach ( function ( topic ) {
156+ topic . title = Beep . parseContent ( topic . title ) ;
157+ topic . slug = Beep . parseContent ( topic . slug ) ;
158+ topic . titleRaw = Beep . parseContent ( topic . titleRaw ) ;
159+ } ) ;
160+ callback ( null , data ) ;
161+ }
162+ }
163+ } ,
150164 post : {
151165 getFields : function ( data , callback ) {
152166 if ( data . fields . indexOf ( 'content' ) !== - 1 ) {
0 commit comments