Skip to content
Merged
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
11 changes: 8 additions & 3 deletions ext/openssl/ossl_x509attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ ossl_x509attr_new(X509_ATTRIBUTE *attr)
VALUE obj;

obj = NewX509Attr(cX509Attr);
new = X509_ATTRIBUTE_dup(attr);
if (!new)
ossl_raise(eX509AttrError, "X509_ATTRIBUTE_dup");
if (!attr) {
new = X509_ATTRIBUTE_new();
} else {
new = X509_ATTRIBUTE_dup(attr);
}
if (!new) {
ossl_raise(eX509AttrError, NULL);
}
SetX509Attr(obj, new);

return obj;
Expand Down
11 changes: 8 additions & 3 deletions ext/openssl/ossl_x509cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ ossl_x509_new(X509 *x509)
VALUE obj;

obj = NewX509(cX509Cert);
new = X509_dup(x509);
if (!new)
ossl_raise(eX509CertError, "X509_dup");
if (!x509) {
new = X509_new();
} else {
new = X509_dup(x509);
}
if (!new) {
ossl_raise(eX509CertError, NULL);
}
SetX509(obj, new);

return obj;
Expand Down
5 changes: 2 additions & 3 deletions ext/openssl/ossl_x509crl.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ ossl_x509crl_new(X509_CRL *crl)
VALUE obj;

obj = NewX509CRL(cX509CRL);
tmp = X509_CRL_dup(crl);
if (!tmp)
ossl_raise(eX509CRLError, "X509_CRL_dup");
tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new();
if(!tmp) ossl_raise(eX509CRLError, NULL);
SetX509CRL(obj, tmp);

return obj;
Expand Down
11 changes: 8 additions & 3 deletions ext/openssl/ossl_x509ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ ossl_x509ext_new(X509_EXTENSION *ext)
VALUE obj;

obj = NewX509Ext(cX509Ext);
new = X509_EXTENSION_dup(ext);
if (!new)
ossl_raise(eX509ExtError, "X509_EXTENSION_dup");
if (!ext) {
new = X509_EXTENSION_new();
} else {
new = X509_EXTENSION_dup(ext);
}
if (!new) {
ossl_raise(eX509ExtError, NULL);
}
SetX509Ext(obj, new);

return obj;
Expand Down
11 changes: 8 additions & 3 deletions ext/openssl/ossl_x509name.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ ossl_x509name_new(X509_NAME *name)
VALUE obj;

obj = NewX509Name(cX509Name);
new = X509_NAME_dup(name);
if (!new)
ossl_raise(eX509NameError, "X509_NAME_dup");
if (!name) {
new = X509_NAME_new();
} else {
new = X509_NAME_dup(name);
}
if (!new) {
ossl_raise(eX509NameError, NULL);
}
SetX509Name(obj, new);

return obj;
Expand Down
11 changes: 8 additions & 3 deletions ext/openssl/ossl_x509revoked.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ ossl_x509revoked_new(X509_REVOKED *rev)
VALUE obj;

obj = NewX509Rev(cX509Rev);
new = X509_REVOKED_dup(rev);
if (!new)
ossl_raise(eX509RevError, "X509_REVOKED_dup");
if (!rev) {
new = X509_REVOKED_new();
} else {
new = X509_REVOKED_dup(rev);
}
if (!new) {
ossl_raise(eX509RevError, NULL);
}
SetX509Rev(obj, new);

return obj;
Expand Down
9 changes: 7 additions & 2 deletions lib/English.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ Gem::Specification.new do |spec|

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
excludes = %W[
:^/test :^/spec :^/feature :^/bin
:^/Rakefile :^/Gemfile\* :^/.git*
:^/#{File.basename(__FILE__)}
]
spec.files = IO.popen(%W[git ls-files -z --] + excludes, err: IO::NULL) do |f|
f.readlines("\x0", chomp: true)
end
spec.require_paths = ["lib"]
end
27 changes: 1 addition & 26 deletions test/ruby/test_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1309,32 +1309,7 @@ def test_pack
assert_equal(ary.join(':'), ary2.join(':'))
assert_not_nil(x =~ /def/)

=begin
skipping "Not tested:
D,d & double-precision float, native format\\
E & double-precision float, little-endian byte order\\
e & single-precision float, little-endian byte order\\
F,f & single-precision float, native format\\
G & double-precision float, network (big-endian) byte order\\
g & single-precision float, network (big-endian) byte order\\
I & unsigned integer\\
i & integer\\
L & unsigned long\\
l & long\\

N & long, network (big-endian) byte order\\
n & short, network (big-endian) byte-order\\
P & pointer to a structure (fixed-length string)\\
p & pointer to a null-terminated string\\
S & unsigned short\\
s & short\\
V & long, little-endian byte order\\
v & short, little-endian byte order\\
X & back up a byte\\
x & null byte\\
Z & ASCII string (null padded, count is width)\\
"
=end
# more comprehensive tests are in test_pack.rb
end

def test_pack_with_buffer
Expand Down
40 changes: 10 additions & 30 deletions test/ruby/test_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2469,33 +2469,7 @@ def test_unpack

assert_equal([0xa9, 0x42, 0x2260], S("\xc2\xa9B\xe2\x89\xa0").unpack(S("U*")))

=begin
skipping "Not tested:
D,d & double-precision float, native format\\
E & double-precision float, little-endian byte order\\
e & single-precision float, little-endian byte order\\
F,f & single-precision float, native format\\
G & double-precision float, network (big-endian) byte order\\
g & single-precision float, network (big-endian) byte order\\
I & unsigned integer\\
i & integer\\
L & unsigned long\\
l & long\\

m & string encoded in base64 (uuencoded)\\
N & long, network (big-endian) byte order\\
n & short, network (big-endian) byte-order\\
P & pointer to a structure (fixed-length string)\\
p & pointer to a null-terminated string\\
S & unsigned short\\
s & short\\
V & long, little-endian byte order\\
v & short, little-endian byte order\\
X & back up a byte\\
x & null byte\\
Z & ASCII string (null padded, count is width)\\
"
=end
# more comprehensive tests are in test_pack.rb
end

def test_upcase
Expand Down Expand Up @@ -2845,13 +2819,15 @@ def test_substr_negative_begin
assert_equal("\u3042", ("\u3042" * 100)[-1])
end

=begin
def test_compare_different_encoding_string
s1 = S("\xff".force_encoding("UTF-8"))
s2 = S("\xff".force_encoding("ISO-2022-JP"))
assert_equal([-1, 1], [s1 <=> s2, s2 <=> s1].sort)

s3 = S("あ".force_encoding("UTF-16LE"))
s4 = S("a".force_encoding("IBM437"))
assert_equal([-1, 1], [s3 <=> s4, s4 <=> s3].sort)
end
=end

def test_casecmp
assert_equal(0, S("FoO").casecmp("fOO"))
Expand Down Expand Up @@ -2953,7 +2929,6 @@ def test_lstrip_bang
s5 = S("\u0000\u3042")
assert_equal("\u3042", s5.lstrip!)
assert_equal("\u3042", s5)

end

def test_delete_prefix_type_error
Expand Down Expand Up @@ -3321,6 +3296,11 @@ def test_byteslice

assert_equal(u("\x82")+("\u3042"*9), S("\u3042"*10).byteslice(2, 28))

assert_equal("\xE3", S("こんにちは").byteslice(0))
assert_equal("こんにちは", S("こんにちは").byteslice(0, 15))
assert_equal("こ", S("こんにちは").byteslice(0, 3))
assert_equal("は", S("こんにちは").byteslice(12, 15))

bug7954 = '[ruby-dev:47108]'
assert_equal(false, S("\u3042").byteslice(0, 2).valid_encoding?, bug7954)
assert_equal(false, ("\u3042"*10).byteslice(0, 20).valid_encoding?, bug7954)
Expand Down