diff options
author | Andreas Gohr <andi@splitbrain.org> | 2006-09-26 21:24:20 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2006-09-26 21:24:20 +0200 |
commit | 041d1964bde2693df05726690877835ddae4e83e (patch) | |
tree | e16bedd108dddd303c19244a393b2013ee3b859c | |
parent | 0a69dff7134e858ffe6b95410196a8712522167b (diff) | |
download | rpg-041d1964bde2693df05726690877835ddae4e83e.tar.gz rpg-041d1964bde2693df05726690877835ddae4e83e.tar.bz2 |
wordblock enhancement
The default wordblock.conf provided by the guys at chonqed.org matches agaist
URLS beginning with http. But DokuWiki also links simple www.example.com links.
Spammers used this method to place blacklisted URLs in the Wiki.
This patch constructs full URLs from these shortcut-URLs before applying the
blacklist regexp.
The patch also fixes a problem with the toolbar not appearing when the blacklist
hit and denied saving.
darcs-hash:20060926192420-7ad00-519df90a5953b690428bfa0928de37b3053031b0.gz
-rw-r--r-- | inc/common.php | 5 | ||||
-rw-r--r-- | inc/template.php | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/inc/common.php b/inc/common.php index c2a6903ab..f42ddb1e5 100644 --- a/inc/common.php +++ b/inc/common.php @@ -412,6 +412,9 @@ function checkwordblock(){ if(!$conf['usewordblock']) return false; + // we prepare the text a tiny bit to prevent spammers circumventing URL checks + $text = preg_replace('!(\b)(www\.[\w.:?\-;,]+?\.[\w.:?\-;,]+?[\w/\#~:.?+=&%@\!\-.:?\-;,]+?)([.:?\-;,]*[^\w/\#~:.?+=&%@\!\-.:?\-;,])!i','\1http://\2 \2\3',$TEXT); + $wordblocks = getWordblocks(); //how many lines to read at once (to work around some PCRE limits) if(version_compare(phpversion(),'4.3.0','<')){ @@ -433,7 +436,7 @@ function checkwordblock(){ if(empty($block)) continue; $re[] = $block; } - if(preg_match('#('.join('|',$re).')#si',$TEXT, $match=array())) { + if(preg_match('#('.join('|',$re).')#si',$text, $match=array())) { return true; } } diff --git a/inc/template.php b/inc/template.php index bcfbff8ea..850580773 100644 --- a/inc/template.php +++ b/inc/template.php @@ -237,7 +237,7 @@ function tpl_metaheaders($alt=true){ 'href'=>DOKU_BASE.'lib/exe/css.php?print=1'); // load javascript - $js_edit = ($ACT=='edit' || $ACT=='preview' || $ACT=='recover') ? 1 : 0; + $js_edit = ($ACT=='edit' || $ACT=='preview' || $ACT=='recover' || $ACT=='wordblock' ) ? 1 : 0; $js_write = ($INFO['writable']) ? 1 : 0; if(defined('DOKU_MEDIAMANAGER')){ $js_edit = 1; |