mirror of
				https://github.com/BookStackApp/BookStack.git
				synced 2025-11-03 02:13:16 +03:00 
			
		
		
		
	@@ -91,7 +91,7 @@ class SearchResultsFormatter
 | 
			
		||||
            $offset = 0;
 | 
			
		||||
            $term = mb_strtolower($term);
 | 
			
		||||
            $pos = mb_strpos($text, $term, $offset);
 | 
			
		||||
            while ($pos !== false) {
 | 
			
		||||
            while ($pos !== false && count($matchRefs) < 25) {
 | 
			
		||||
                $end = $pos + mb_strlen($term);
 | 
			
		||||
                $matchRefs[$pos] = $end;
 | 
			
		||||
                $offset = $end;
 | 
			
		||||
 
 | 
			
		||||
@@ -378,6 +378,21 @@ class EntitySearchTest extends TestCase
 | 
			
		||||
        $search->assertSee('<strong>На</strong> <strong>мен</strong> <strong>ми</strong> <strong>трябва</strong> <strong>нещо</strong> <strong>добро</strong> test', false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function test_match_highlighting_is_efficient_with_large_frequency_in_content()
 | 
			
		||||
    {
 | 
			
		||||
        $content = str_repeat('superbeans ', 10000);
 | 
			
		||||
        $this->entities->newPage([
 | 
			
		||||
            'name' => 'Test Page',
 | 
			
		||||
            'html' => "<p>{$content}</p>",
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        $time = microtime(true);
 | 
			
		||||
        $resp = $this->asEditor()->get('/search?term=' . urlencode('superbeans'));
 | 
			
		||||
        $this->assertLessThan(0.5, microtime(true) - $time);
 | 
			
		||||
 | 
			
		||||
        $resp->assertSee('<strong>superbeans</strong>', false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function test_html_entities_in_item_details_remains_escaped_in_search_results()
 | 
			
		||||
    {
 | 
			
		||||
        $this->entities->newPage(['name' => 'My <cool> TestPageContent', 'html' => '<p>My supercool <great> TestPageContent page</p>']);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user