[rubygems/rubygems] Restore treating "--" as an unknown platform

Rather than crashing when parsing it.

aa0064e4c7
This commit is contained in:
David Rodríguez 2025-07-16 18:29:13 +02:00 committed by Hiroshi SHIBATA
parent 45b53c0be1
commit 851a3e7724
2 changed files with 3 additions and 1 deletions

View file

@ -90,7 +90,7 @@ class Gem::Platform
when String then when String then
cpu, os = arch.sub(/-+$/, "").split("-", 2) cpu, os = arch.sub(/-+$/, "").split("-", 2)
@cpu = if cpu.match?(/i\d86/) @cpu = if cpu&.match?(/i\d86/)
"x86" "x86"
else else
cpu cpu

View file

@ -162,6 +162,8 @@ class TestGemPlatform < Gem::TestCase
"x86_64-dotnetx86" => ["x86_64", "dotnet", nil], "x86_64-dotnetx86" => ["x86_64", "dotnet", nil],
"x86_64-dalvik0" => ["x86_64", "dalvik", "0"], "x86_64-dalvik0" => ["x86_64", "dalvik", "0"],
"x86_64-dotnet1." => ["x86_64", "dotnet", "1"], "x86_64-dotnet1." => ["x86_64", "dotnet", "1"],
"--" => [nil, "unknown", nil],
} }
test_cases.each do |arch, expected| test_cases.each do |arch, expected|