Closed ebgc closed 4 months ago
I'm encountering something that I think is similar. When I send and echo µsomemessage
- where µ
is a valid character in both UTF-8 and Windows-1252 (my target system's encoding) - I get 'invalid byte sequence' when run from Windows (but behaves okay from macOS/Linux). In particular
µ
but Ruby thinks it's a UTF-8 string. Under some scenarios where I use the string, I get 'invalid byte sequence' because the Windows-1252 byte sequence of µ
isn't a valid UTF-8 byte sequence.Update: this seems to specifically affect Ruby 2.3 on Windows. Seems fixed under Ruby 2.4.
Hi - looking at the trace of the original issue, this bug is in rubyntlm and should be addressed in https://github.com/WinRb/rubyntlm/pull/56
For @MikaelSmith's issue - glad to hear this is not an issue in ruby 2.4, but if you can reproduce, please provide a stacktrace. Thanks
hi
using below script throws an error. trying it with username 'user' and it works.
-- 1.rb -----------8<---------------
require 'winrm'
user = "サザ" pass = 'secret' end = '1.2.3.4'
opts = { endpoint: "http://#{end}/wsman", user: user, password: pass, overall_timeout: 5, retry_limit: 1, retry_delay: 1 }
conn = WinRM::Connection.new(opts) conn.shell(:cmd) do |shell| output = shell.run("dir") do |stdout, stderr| p "stdout: #{stdout}" p "stderr: #{stderr}" end puts "The script exited with exit code #{output.exitcode}" end -- 1.rb ----------------->8-----------------
running this gives and error: ----------------- execute and error ----------------------
> bundle exec ruby 1.rb
/Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm.rb:164:in'
----------------- execute and error ----------------------
upcase': invalid byte sequence in UTF-8 (ArgumentError) from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm.rb:164:in
ntlmv2_hash' from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client/session.rb:192:inntlmv2_hash' from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client/session.rb:196:in
calculate_user_session_key!' from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client/session.rb:27:inauthenticate!' from /Users/user/dddd/bundles/ruby/2.2.0/gems/rubyntlm-0.6.2/lib/net/ntlm/client.rb:36:in
init_context' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/http/transport.rb:229:ininit_auth' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/http/transport.rb:168:in
send_request' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/cmd.rb:56:inopen_shell' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:168:in
block in open' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/retryable.rb:37:inretryable' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:166:in
open' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:129:inwith_command_shell' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/shells/base.rb:81:in
run' from 1.rb:20:inblock in <main>' from /Users/user/dddd/bundles/ruby/2.2.0/gems/winrm-2.2.3/lib/winrm/connection.rb:44:in
shell' from 1.rb:19:in `any idea ?