mirror of
https://github.com/discourse/discourse.git
synced 2026-08-13 06:25:11 -05:00
FIX: Escape regex pattern variable before using it
This commit is contained in:
@@ -44,7 +44,7 @@ module I18n
|
|||||||
results = {}
|
results = {}
|
||||||
|
|
||||||
fallbacks(locale).each do |fallback|
|
fallbacks(locale).each do |fallback|
|
||||||
find_results(/#{query}/i, results, translations[fallback])
|
find_results(/#{Regexp.escape(query)}/i, results, translations[fallback])
|
||||||
end
|
end
|
||||||
|
|
||||||
results
|
results
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ describe I18n::Backend::DiscourseI18n do
|
|||||||
backend.store_translations(:en, items: { one: 'one item', other: "%{count} items" })
|
backend.store_translations(:en, items: { one: 'one item', other: "%{count} items" })
|
||||||
backend.store_translations(:de, bar: 'Bar in :de')
|
backend.store_translations(:de, bar: 'Bar in :de')
|
||||||
backend.store_translations(:ru, baz: 'Baz in :ru')
|
backend.store_translations(:ru, baz: 'Baz in :ru')
|
||||||
|
backend.store_translations(:en, link: '[text](url)')
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
@@ -32,6 +33,7 @@ describe I18n::Backend::DiscourseI18n do
|
|||||||
expect(backend.search(:en, 'Foo')).to eq('foo' => 'Foo in :en')
|
expect(backend.search(:en, 'Foo')).to eq('foo' => 'Foo in :en')
|
||||||
expect(backend.search(:en, 'hello')).to eq('wat' => 'Hello %{count}')
|
expect(backend.search(:en, 'hello')).to eq('wat' => 'Hello %{count}')
|
||||||
expect(backend.search(:en, 'items.one')).to eq('items.one' => 'one item')
|
expect(backend.search(:en, 'items.one')).to eq('items.one' => 'one item')
|
||||||
|
expect(backend.search(:en, '](')).to eq('link' => '[text](url)')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can return multiple results' do
|
it 'can return multiple results' do
|
||||||
|
|||||||
Reference in New Issue
Block a user