File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed
Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -42,11 +42,12 @@ unixsock_path_value(VALUE path)
4242 }
4343 }
4444#endif
45+ path = rb_get_path (path );
4546#ifdef _WIN32
4647 /* UNIXSocket requires UTF-8 per spec. */
4748 path = rb_str_export_to_enc (path , rb_utf8_encoding ());
4849#endif
49- return rb_get_path ( path ) ;
50+ return path ;
5051}
5152
5253VALUE
Original file line number Diff line number Diff line change @@ -293,14 +293,18 @@ def bound_unix_socket(klass)
293293 File . unlink path if path && File . socket? ( path )
294294 end
295295
296- def test_open_nul_byte
297- tmpfile = Tempfile . new ( "s" )
298- path = tmpfile . path
299- tmpfile . close ( true )
300- assert_raise ( ArgumentError ) { UNIXServer . open ( path +"\0 " ) }
301- assert_raise ( ArgumentError ) { UNIXSocket . open ( path +"\0 " ) }
302- ensure
303- File . unlink path if path && File . socket? ( path )
296+ def test_open_argument
297+ assert_raise ( TypeError ) { UNIXServer . new ( nil ) }
298+ assert_raise ( TypeError ) { UNIXServer . new ( 1 ) }
299+ Tempfile . create ( "s" ) do |s |
300+ path = s . path
301+ s . close
302+ File . unlink ( path )
303+ assert_raise ( ArgumentError ) { UNIXServer . open ( path +"\0 " ) }
304+ assert_raise ( ArgumentError ) { UNIXSocket . open ( path +"\0 " ) }
305+ arg = Struct . new ( :to_path ) . new ( path )
306+ assert_equal ( path , UNIXServer . open ( arg ) { |server | server . path } )
307+ end
304308 end
305309
306310 def test_addr
You can’t perform that action at this time.
0 commit comments