mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
FIX: a search term containing '& could lead to errors
This also makes sure that the search term in front or after special characters isn't ignored.
This commit is contained in:
@ -945,12 +945,18 @@ describe Search do
|
||||
end
|
||||
end
|
||||
|
||||
it 'can parse complex strings using ts_query helper' do
|
||||
str = " grigio:babel deprecated? "
|
||||
str << "page page on Atmosphere](https://atmospherejs.com/grigio/babel)xxx: aaa.js:222 aaa'\"bbb"
|
||||
context '#ts_query' do
|
||||
it 'can parse complex strings using ts_query helper' do
|
||||
str = " grigio:babel deprecated? "
|
||||
str << "page page on Atmosphere](https://atmospherejs.com/grigio/babel)xxx: aaa.js:222 aaa'\"bbb"
|
||||
|
||||
ts_query = Search.ts_query(term: str, ts_config: "simple")
|
||||
DB.exec("SELECT to_tsvector('bbb') @@ " << ts_query)
|
||||
ts_query = Search.ts_query(term: str, ts_config: "simple")
|
||||
expect { DB.exec("SELECT to_tsvector('bbb') @@ " << ts_query) }.to_not raise_error
|
||||
|
||||
ts_query = Search.ts_query(term: "foo.bar/'&baz", ts_config: "simple")
|
||||
expect { DB.exec("SELECT to_tsvector('bbb') @@ " << ts_query) }.to_not raise_error
|
||||
expect(ts_query).to include("baz")
|
||||
end
|
||||
end
|
||||
|
||||
context '#word_to_date' do
|
||||
|
Reference in New Issue
Block a user