summaryrefslogtreecommitdiff
path: root/inc/html.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2010-10-02 18:38:27 +0200
committerAndreas Gohr <andi@splitbrain.org>2010-10-02 18:38:27 +0200
commitfeb563fa9c27209131711d3ef93ebf1f74aadb0d (patch)
tree4b0752ffd7c50b320b5f4992f59e82c0309c66a3 /inc/html.php
parentf3f7087bd8d0b583a3add1b38877a2b9ef39322e (diff)
parent26eb848c36688e459e5dfc46cdc68d87ed2bda0c (diff)
downloadrpg-feb563fa9c27209131711d3ef93ebf1f74aadb0d.tar.gz
rpg-feb563fa9c27209131711d3ef93ebf1f74aadb0d.tar.bz2
Merge branch 'master' of github.com:splitbrain/dokuwiki
Diffstat (limited to 'inc/html.php')
-rw-r--r--inc/html.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/inc/html.php b/inc/html.php
index add559971..e1478b0a8 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -285,7 +285,7 @@ function html_draft(){
*/
function html_hilight($html,$phrases){
$phrases = array_filter((array) $phrases);
- $regex = join('|',array_map('preg_quote_cb',$phrases));
+ $regex = join('|',array_map('_html_hilight_re_preprocess', array_map('preg_quote_cb',$phrases)));
if ($regex === '') return $html;
$html = preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html);
@@ -293,6 +293,13 @@ function html_hilight($html,$phrases){
}
/**
+ * Wraps a search term in regex boundary checks.
+ */
+function _html_hilight_re_preprocess($term) {
+ return '\b'.$term.'\b';
+}
+
+/**
* Callback used by html_hilight()
*
* @author Harry Fuecks <hfuecks@gmail.com>