Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/rubygems/yaml_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def parse_node(base_indent)

if stripped.start_with?("- ") || stripped == "-"
parse_sequence(indent, anchor)
elsif stripped.start_with?("\"") && stripped.end_with?("\"")
parse_plain_scalar(indent, anchor)
elsif stripped.start_with?("'") && stripped.end_with?("'")
parse_plain_scalar(indent, anchor)
elsif stripped =~ MAPPING_KEY_RE && !stripped.start_with?("!ruby/object:")
Comment on lines 96 to 102
parse_mapping(indent, anchor)
elsif stripped.start_with?("!ruby/object:")
Expand Down
14 changes: 14 additions & 0 deletions test/rubygems/test_gem_safe_yaml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,20 @@ def test_requirements_hash_converted_to_array
assert_kind_of Hash, reqs
end

def test_requirement_quote
yaml = <<~YAML
requirements:
- "system: arrow-glib>=25.0.0: amazon_linux: arrow-glib-devel"
- 'system: arrow-glib>=25.0.0: fedora: libarrow-glib-devel'
YAML

expected = [
"system: arrow-glib>=25.0.0: amazon_linux: arrow-glib-devel",
"system: arrow-glib>=25.0.0: fedora: libarrow-glib-devel",
]
assert_equal expected, yaml_load(yaml)["requirements"]
end
Comment on lines +321 to +333

def test_rdoc_options_hash_converted_to_array
# Some gemspecs incorrectly have rdoc_options: {} instead of rdoc_options: []
yaml = <<~YAML
Expand Down
Loading