diff --git a/inc/common.php b/inc/common.php index c943ffa3cf55a1e034e1e74dd68bc94ab2a3e45b..b5c29d621c4043967c6fb1fcb68540bec5eb2dea 100644 --- a/inc/common.php +++ b/inc/common.php @@ -365,7 +365,7 @@ function checkwordblock(){ if(!$conf['usewordblock']) return false; - $blockfile = file(DOKU_CONF.'wordblock.conf'); + $wordblocks = getWordblocks(); //how many lines to read at once (to work around some PCRE limits) if(version_compare(phpversion(),'4.3.0','<')){ //old versions of PCRE define a maximum of parenthesises even if no @@ -377,7 +377,7 @@ function checkwordblock(){ //MAX_PATTERN_SIZE in modern PCRE $chunksize = 600; } - while($blocks = array_splice($blockfile,0,$chunksize)){ + while($blocks = array_splice($wordblocks,0,$chunksize)){ $re = array(); #build regexp from blocks foreach($blocks as $block){ @@ -386,7 +386,9 @@ function checkwordblock(){ if(empty($block)) continue; $re[] = $block; } - if(preg_match('#('.join('|',$re).')#si',$TEXT)) return true; + if(preg_match('#('.join('|',$re).')#si',$TEXT, $match=array())) { + return true; + } } return false; } diff --git a/inc/confutils.php b/inc/confutils.php index 9432c10d594549599f503f3e0df4ebb64a50ade9..cc1d8064a505a4898e86291366a697dd11e309dc 100644 --- a/inc/confutils.php +++ b/inc/confutils.php @@ -115,6 +115,23 @@ function getInterwiki() { return $wikis; } +/** + * returns array of wordblock patterns + * + */ +function getWordblocks() { + static $wordblocks = NULL; + if ( !$wordblocks ) { + $wordblocks = file(DOKU_CONF.'wordblock.conf'); + if (@file_exists(DOKU_CONF.'wordblock.local.conf')) { + $local = file(DOKU_CONF.'wordblock.local.conf'); + $wordblocks = array_merge($wordblocks, $local); + } + } + return $wordblocks; +} + + /** * Builds a hash from a configfile *