mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Merge branch 'esakkiraja100116/development' into development
This commit is contained in:
commit
277d5392fb
@ -173,6 +173,7 @@ class SearchRunner
|
||||
// Handle exact term matching
|
||||
foreach ($searchOpts->exacts as $inputTerm) {
|
||||
$entityQuery->where(function (EloquentBuilder $query) use ($inputTerm, $entityModelInstance) {
|
||||
$inputTerm = str_replace('\\', '\\\\', $inputTerm);
|
||||
$query->where('name', 'like', '%' . $inputTerm . '%')
|
||||
->orWhere($entityModelInstance->textField, 'like', '%' . $inputTerm . '%');
|
||||
});
|
||||
@ -218,6 +219,7 @@ class SearchRunner
|
||||
$subQuery->where('entity_type', '=', $entity->getMorphClass());
|
||||
$subQuery->where(function (Builder $query) use ($terms) {
|
||||
foreach ($terms as $inputTerm) {
|
||||
$inputTerm = str_replace('\\', '\\\\', $inputTerm);
|
||||
$query->orWhere('term', 'like', $inputTerm . '%');
|
||||
}
|
||||
});
|
||||
@ -354,6 +356,9 @@ class SearchRunner
|
||||
$tagValue = (float) trim($connection->getPdo()->quote($tagValue), "'");
|
||||
$query->whereRaw("value {$tagOperator} {$tagValue}");
|
||||
} else {
|
||||
if ($tagOperator === 'like') {
|
||||
$tagValue = str_replace('\\', '\\\\', $tagValue);
|
||||
}
|
||||
$query->where('value', $tagOperator, $tagValue);
|
||||
}
|
||||
} else {
|
||||
|
@ -444,6 +444,26 @@ class EntitySearchTest extends TestCase
|
||||
$search->assertSee($page->getUrl(), false);
|
||||
}
|
||||
|
||||
public function test_backslashes_can_be_searched_upon()
|
||||
{
|
||||
$page = $this->entities->newPage(['name' => 'TermA', 'html' => '
|
||||
<p>More info is at the path \\\\cat\\dog\\badger</p>
|
||||
']);
|
||||
$page->tags()->save(new Tag(['name' => '\\Category', 'value' => '\\animals\\fluffy']));
|
||||
|
||||
$search = $this->asEditor()->get('/search?term=' . urlencode('\\\\cat\\dog'));
|
||||
$search->assertSee($page->getUrl(), false);
|
||||
|
||||
$search = $this->asEditor()->get('/search?term=' . urlencode('"\\dog\\"'));
|
||||
$search->assertSee($page->getUrl(), false);
|
||||
|
||||
$search = $this->asEditor()->get('/search?term=' . urlencode('"\\badger\\"'));
|
||||
$search->assertDontSee($page->getUrl(), false);
|
||||
|
||||
$search = $this->asEditor()->get('/search?term=' . urlencode('[\\Categorylike%\\fluffy]'));
|
||||
$search->assertSee($page->getUrl(), false);
|
||||
}
|
||||
|
||||
public function test_searches_with_user_filters_adds_them_into_advanced_search_form()
|
||||
{
|
||||
$resp = $this->asEditor()->get('/search?term=' . urlencode('test {updated_by:dan} {created_by:dan}'));
|
||||
|
Loading…
Reference in New Issue
Block a user