Skip to content

Commit 2950cea

Browse files
mokagioclaude
andcommitted
Add failing test for merge_strings nested-dict crash
`L10nHelper.merge_strings` bookkeeps keys via `plutil` (which parses a nested-dictionary value fine) but re-tokenizes the raw lines through `prefix_keys`, which raises `Invalid character` on the `{`. Such a file is a valid property list, still detected as `:text`, so it passes the format gate and reaches `prefix_keys` — a public `ios_merge_strings_files` run that previously copied the line through now aborts. This stacks a regression test on top of #741 and is intentionally left red so the reviewer can decide how to make the path fail-soft (e.g. rescue and copy the line verbatim, matching the scanner path). --- Generated with the help of Claude Code, https://claude.com/claude-code Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9eabbb0 commit 2950cea

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

spec/ios_l10n_helper_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,22 @@ def file_encoding(path)
160160
end
161161
end
162162

163+
it 'does not crash merging a text `.strings` file whose value is a nested dictionary' do
164+
# Regression: `merge_strings` bookkeeps keys via `plutil` (which parses a nested-dictionary value
165+
# fine) but re-tokenizes the raw lines through `prefix_keys`, which raises `Invalid character` on
166+
# the `{`. Such a file is still `:text` and passes the format gate, so a public `ios_merge_strings_files`
167+
# run that previously copied the line through now aborts. It should degrade gracefully instead of raising.
168+
content = %("k" = { a = b; };\n)
169+
Dir.mktmpdir('a8c-release-toolkit-l10n-helper-tests-') do |tmp_dir|
170+
input_file = File.join(tmp_dir, 'InfoPlist.strings')
171+
File.write(input_file, content)
172+
output_file = File.join(tmp_dir, 'output.strings')
173+
expect do
174+
described_class.merge_strings(paths: { input_file => 'pfx.' }, output_path: output_file)
175+
end.not_to raise_error
176+
end
177+
end
178+
163179
it 'returns duplicate keys found' do
164180
paths = { fixture('Localizable-utf16.strings') => nil, fixture('non-latin-utf16.strings') => nil }
165181
Dir.mktmpdir('a8c-release-toolkit-l10n-helper-tests-') do |tmp_dir|

0 commit comments

Comments
 (0)