Skip to content

Commit 92b9791

Browse files
committed
fbforum: allow underscores in phpBB index and search terms
- allows indexing of code blocks - allows words with underscores to be indexed - allows user search terms to have underscores
1 parent b100ef3 commit 92b9791

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

phpbb/search/fulltext_native.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ public function split_keywords($keywords, $terms)
304304
{
305305
$words = array();
306306

307-
preg_match_all('#([^\\s+\\-|()]+)(?:$|[\\s+\\-|()])#u', $keywords, $words);
307+
// fb.net - allow underscores in words
308+
// original: preg_match_all('#([^\\s+\\-|()]+)(?:$|[\\s+\\-|()])#u', $keywords, $words);
309+
310+
preg_match_all('#([^\\s+\\-|()\_]+)(?:$|[\\s+\\-|()])#u', $keywords, $words);
311+
308312
if (count($words[1]))
309313
{
310314
$keywords = '(' . implode('|', $words[1]) . ')';
@@ -1343,9 +1347,9 @@ public function split_message($text)
13431347
/**
13441348
* Taken from the original code
13451349
*/
1350+
// fb.net - allow code to be indexed by commenting out the rule
13461351
// Do not index code
1347-
$match[] = '#\[code(?:=.*?)?(\:?[0-9a-z]{5,})\].*?\[\/code(\:?[0-9a-z]{5,})\]#is';
1348-
// BBcode
1352+
// original: $match[] = '#\[code(?:=.*?)?(\:?[0-9a-z]{5,})\].*?\[\/code(\:?[0-9a-z]{5,})\]#is';
13491353
$match[] = '#\[\/?[a-z0-9\*\+\-]+(?:=.*?)?(?::[a-z])?(\:?[0-9a-z]{5,})\]#';
13501354

13511355
$min = $this->word_length['min'];
@@ -1847,14 +1851,20 @@ protected function cleanup($text, $allowed_chars = null, $encoding = 'utf-8')
18471851
*
18481852
* @todo in theory, the third one is already taken care of during normalization and those chars should have been replaced by Unicode replacement chars
18491853
*/
1854+
18501855
$sb_match = "ISTCPAMELRDOJBNHFGVWUQKYXZ\r\n\t!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\xC0\xC1\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF";
1851-
$sb_replace = 'istcpamelrdojbnhfgvwuqkyxz ';
1856+
1857+
// fb.net - allow underscores in words
1858+
// original: $sb_replace = 'istcpamelrdojbnhfgvwuqkyxz ';
1859+
$sb_replace = 'istcpamelrdojbnhfgvwuqkyxz _ ';
18521860

18531861
/**
18541862
* This is the list of legal ASCII chars, it is automatically extended
18551863
* with ASCII chars from $allowed_chars
18561864
*/
1857-
$legal_ascii = ' eaisntroludcpmghbfvq10xy2j9kw354867z';
1865+
// fb.net - allow underscores in words
1866+
// original: $legal_ascii = ' eaisntroludcpmghbfvq10xy2j9kw354867z';
1867+
$legal_ascii = ' eaisntroludcpmghbfvq10xy2j9kw354867z_';
18581868

18591869
/**
18601870
* Prepare an array containing the extra chars to allow

0 commit comments

Comments
 (0)