diff --git a/lib/i18n/backend/discourse_i18n.rb b/lib/i18n/backend/discourse_i18n.rb index fec8150c79f..553de8eb50e 100644 --- a/lib/i18n/backend/discourse_i18n.rb +++ b/lib/i18n/backend/discourse_i18n.rb @@ -44,7 +44,7 @@ module I18n results = {} fallbacks(locale).each do |fallback| - find_results(/#{query}/i, results, translations[fallback]) + find_results(/#{Regexp.escape(query)}/i, results, translations[fallback]) end results diff --git a/spec/components/discourse_i18n_spec.rb b/spec/components/discourse_i18n_spec.rb index 72dfc368ce5..bf51e6e7251 100644 --- a/spec/components/discourse_i18n_spec.rb +++ b/spec/components/discourse_i18n_spec.rb @@ -12,6 +12,7 @@ describe I18n::Backend::DiscourseI18n do backend.store_translations(:en, items: { one: 'one item', other: "%{count} items" }) backend.store_translations(:de, bar: 'Bar in :de') backend.store_translations(:ru, baz: 'Baz in :ru') + backend.store_translations(:en, link: '[text](url)') end 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, 'hello')).to eq('wat' => 'Hello %{count}') expect(backend.search(:en, 'items.one')).to eq('items.one' => 'one item') + expect(backend.search(:en, '](')).to eq('link' => '[text](url)') end it 'can return multiple results' do