|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -RSpec.shared_context 'i18n value base matrix' do |
| 3 | +RSpec.shared_context 'with i18n value base matrix' do |
4 | 4 | let(:safe_input) { 't(admin.my_text)' } |
5 | 5 | let(:quoted_safe_input) { 't( "admin.my_text" )' } |
6 | 6 | let(:expected_translation) { 'My Text' } |
7 | 7 | let(:plain_input) { 'Regular label' } |
8 | 8 | end |
9 | 9 |
|
10 | | -RSpec.shared_context 'i18n value malformed payload matrix' do |
| 10 | +RSpec.shared_context 'with i18n value malformed payload matrix' do |
11 | 11 | let(:malformed_payloads) do |
12 | 12 | [ |
13 | 13 | "t(admin.my_text, default: 'fallback')", |
|
19 | 19 | end |
20 | 20 | end |
21 | 21 |
|
22 | | -RSpec.shared_context 'i18n value malicious payload matrix' do |
| 22 | +RSpec.shared_context 'with i18n value malicious payload matrix' do |
23 | 23 | let(:malicious_payloads) do |
24 | 24 | [ |
25 | 25 | "t(Kernel.system('echo pwned'))", |
26 | 26 | 't(File.read("/etc/passwd"))', |
27 | | - "t(%x[echo pwned])" |
| 27 | + 't(%x[echo pwned])' |
28 | 28 | ] |
29 | 29 | end |
30 | 30 | end |
31 | 31 |
|
32 | 32 | RSpec.shared_examples 'i18n value translation safety' do |
33 | | - include_context 'i18n value base matrix' |
34 | | - include_context 'i18n value malformed payload matrix' |
35 | | - include_context 'i18n value malicious payload matrix' |
| 33 | + include_context 'with i18n value base matrix' |
| 34 | + include_context 'with i18n value malformed payload matrix' |
| 35 | + include_context 'with i18n value malicious payload matrix' |
36 | 36 |
|
37 | 37 | it 'translates safe i18n key expressions' do |
38 | 38 | expect(render_i18n_value(safe_input)).to eq(expected_translation) |
|
0 commit comments