From 3222c672628dba20367475cfaf832b82b2cc3d4c Mon Sep 17 00:00:00 2001 From: alpha0x00 Date: Sun, 14 Jul 2024 22:01:57 +0800 Subject: [PATCH] [rubygems/rubygems] Fix line comment issue for map https://github.com/rubygems/rubygems/commit/7ca06e139b --- lib/bundler/yaml_serializer.rb | 2 +- lib/rubygems/yaml_serializer.rb | 2 +- test/rubygems/test_gem_config_file.rb | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/bundler/yaml_serializer.rb b/lib/bundler/yaml_serializer.rb index 93d08a05aa..ab1eb6dbcf 100644 --- a/lib/bundler/yaml_serializer.rb +++ b/lib/bundler/yaml_serializer.rb @@ -41,7 +41,7 @@ module Bundler HASH_REGEX = / ^ ([ ]*) # indentations - (.+) # key + ([^#]+) # key excludes comment char '#' (?::(?=(?:\s|$))) # : (without the lookahead the #key includes this when : is present in value) [ ]? (['"]?) # optional opening quote diff --git a/lib/rubygems/yaml_serializer.rb b/lib/rubygems/yaml_serializer.rb index af86c63ef7..f89004f32a 100644 --- a/lib/rubygems/yaml_serializer.rb +++ b/lib/rubygems/yaml_serializer.rb @@ -41,7 +41,7 @@ module Gem HASH_REGEX = / ^ ([ ]*) # indentations - (.+) # key + ([^#]+) # key excludes comment char '#' (?::(?=(?:\s|$))) # : (without the lookahead the #key includes this when : is present in value) [ ]? (['"]?) # optional opening quote diff --git a/test/rubygems/test_gem_config_file.rb b/test/rubygems/test_gem_config_file.rb index b28dcf503e..4230eda4d3 100644 --- a/test/rubygems/test_gem_config_file.rb +++ b/test/rubygems/test_gem_config_file.rb @@ -569,10 +569,14 @@ if you believe they were disclosed to a third party. yaml = <<~YAML --- :foo: bar # buzz + #:notkey: bar YAML actual = Gem::ConfigFile.load_with_rubygems_config_hash(yaml) assert_equal("bar", actual[:foo]) + assert_equal(false, actual.key?("#:notkey")) + assert_equal(false, actual.key?(:notkey)) + assert_equal(1, actual.size) end def test_s3_source