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
2 changes: 1 addition & 1 deletion enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -3946,7 +3946,7 @@ chunk_i(RB_BLOCK_CALL_FUNC_ARGLIST(yielder, enumerator))
* ["F", 6860]
*
* You can use the special symbol <tt>:_alone</tt> to force an element
* into its own separate chuck:
* into its own separate chunk:
*
* a = [0, 0, 1, 1]
* e = a.chunk{|i| i.even? ? :_alone : true }
Expand Down
3 changes: 2 additions & 1 deletion ext/socket/unixsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ unixsock_path_value(VALUE path)
}
}
#endif
path = rb_get_path(path);
#ifdef _WIN32
/* UNIXSocket requires UTF-8 per spec. */
path = rb_str_export_to_enc(path, rb_utf8_encoding());
#endif
return rb_get_path(path);
return path;
}

VALUE
Expand Down
20 changes: 12 additions & 8 deletions test/socket/test_unix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,18 @@ def bound_unix_socket(klass)
File.unlink path if path && File.socket?(path)
end

def test_open_nul_byte
tmpfile = Tempfile.new("s")
path = tmpfile.path
tmpfile.close(true)
assert_raise(ArgumentError) {UNIXServer.open(path+"\0")}
assert_raise(ArgumentError) {UNIXSocket.open(path+"\0")}
ensure
File.unlink path if path && File.socket?(path)
def test_open_argument
assert_raise(TypeError) {UNIXServer.new(nil)}
assert_raise(TypeError) {UNIXServer.new(1)}
Tempfile.create("s") do |s|
path = s.path
s.close
File.unlink(path)
assert_raise(ArgumentError) {UNIXServer.open(path+"\0")}
assert_raise(ArgumentError) {UNIXSocket.open(path+"\0")}
arg = Struct.new(:to_path).new(path)
assert_equal(path, UNIXServer.open(arg) { |server| server.path })
end
end

def test_addr
Expand Down