diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-09-03 18:20:02 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-09-03 18:45:26 +0900 |
commit | 19c67cd10c57f3ab7b13966c36431ebc3fdd653b (patch) | |
tree | cb7ead6e5f9ed6b604e6e49298d61b24064b48c6 /lib | |
parent | e96d9c02c4d4788083360fa49d3afcba9ffef289 (diff) | |
download | ruby-openssl-19c67cd10c57f3ab7b13966c36431ebc3fdd653b.tar.gz |
x509name: update regexp in OpenSSL::X509::Name.parseky/x509name-fix-parse-openssl
Allow the attribute value to contain ',', just as the openssl utility's
parse_name() function does.
Fixes: https://github.com/ruby/openssl/issues/39
Diffstat (limited to 'lib')
-rw-r--r-- | lib/openssl/x509.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/openssl/x509.rb b/lib/openssl/x509.rb index aef3456e..6d31b98c 100644 --- a/lib/openssl/x509.rb +++ b/lib/openssl/x509.rb @@ -139,7 +139,13 @@ module OpenSSL end def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE) - ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) } + if str.start_with?("/") + # /A=B/C=D format + ary = str[1..-1].split("/").map { |i| i.split("=", 2) } + else + # Comma-separated + ary = str.split(",").map { |i| i.strip.split("=", 2) } + end self.new(ary, template) end |