$OpenBSD: patch-lib_rubygems_installer_rb,v 1.1 2017/09/02 21:32:07 jeremy Exp $

Index: lib/rubygems/installer.rb
--- lib/rubygems/installer.rb.orig
+++ lib/rubygems/installer.rb
@@ -621,6 +621,11 @@ class Gem::Installer
       unpack or File.writable?(gem_home)
   end
 
+  def verify_spec_name
+    return if spec.name =~ Gem::Specification::VALID_NAME_PATTERN
+    raise Gem::InstallError, "#{spec} has an invalid name"
+  end
+
   ##
   # Return the text for an application file.
 
@@ -745,6 +750,8 @@ TEXT
       @force and @security_policy and not @security_policy.only_signed
 
     ensure_loadable_spec
+
+    verify_spec_name
 
     if options[:install_as_default]
       Gem.ensure_default_gem_subdirectories gem_home
