1

Topic: Censoring problem

Replacement doesn't work as it is supposed, namely all words are replaced as if they are between wildcards.

For example, rule abc => xyz makes abcdef to be replaced with xyzdef

The problem occurs with Russian words only (utf-8 encoding is used), for English words it works correctly.

Any ideas how to fix this?

2

Re: Censoring problem

Ok, I had to Google a lot, but finally with StackOwerflow's help found solution smile

Replace line 809 in functions.php

$search_for[$censor_key] = '/(?<=\W)('.str_replace('\*', '\w*?', preg_quote($cur_word['search_for'], '/')).')(?=\W)/iu';

With

$search_for[$censor_key] = '/(?<!\pL)'.str_replace('\*', '\w*?', preg_quote($cur_word['search_for'], '/')).'(?!\pL)/iu';

And it should work ok wink

Eraversum - scifi browser-based online webgame

3

Re: Censoring problem

Thanks much for your help. However, I got this message:

Warning: preg_replace(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 5...

4 (edited by Grez 2011-03-05 15:52)

Re: Censoring problem

That's bad sad Found out, that \pL isn't supported in old version of PCRE, so you'll to upgrade it...

Anyway, this code should at least check php version and then use newer (working) or older (buggy, but not working properly) syntax neutral
[code=php]if(PHP_VERSION >= 5.1) {
    $search_for[$censor_key] = '/(?<!\pL)'.str_replace('\*', '\w*?', preg_quote($cur_word['search_for'], '/')).'(?!\pL)/iu';
} else {
    //Contains bug with utf8 words, but couldn't find a way to solve it with old pcre sad
    $search_for[$censor_key] = '/(?<=\W)('.str_replace('\*', '\w*?', preg_quote($cur_word['search_for'], '/')).')(?=\W)/iu';
}[/code]

//Grez: Added ticket

Eraversum - scifi browser-based online webgame