Part of the EllisLab Network

Bug Report

word_censor gives error is “/” is in $censored

Date: 10/07/2008 Severity: Minor
Status: Resolved Reporter: Natebot
Version: 1.6.3
Keywords: Helpers, Text Helper

Description

The presence of a forward slash (”/”) in an element of the censored word array used by word_censor text helper will generate an error.

Possible work around is using

preg_quote($badword,'/')

on lines 245 and 249 of text_helper.php.  This will escape “/” and will allow for matching.

Code Sample

$censored = array( 'use/censor' );

$string = word_censor('Sample string where we try to use/censor this sentence.', $censored, '###'));

Expected Result

Sample string where we try to ### this sentence.

Actual Result

A PHP Error was encountered
Severity: Warning
Message: preg_replace() [function.preg-replace]: Unknown modifier ‘c’
Filename: helpers/text_helper.php
Line Number: 245

Comment on Bug Report

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?