Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

japanese username - invalid byte sequence #276

Closed
ebgc opened this issue Sep 21, 2017 · 2 comments
Closed

japanese username - invalid byte sequence #276

ebgc opened this issue Sep 21, 2017 · 2 comments

Comments

@ebgc
Copy link

ebgc commented Sep 21, 2017

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 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:in ntlmv2_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:in authenticate!' 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:in init_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:in open_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:in retryable' 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:in with_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:in block 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 `

'
----------------- execute and error ----------------------

any idea ?

@MikaelSmith
Copy link

MikaelSmith commented Jul 25, 2018

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

  • sent from Windows, I get back the Windows-1252 encoding of µ 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.
  • sent from macOS or Linux, I get back the UTF-8 encoding and the string is expected to be UTF-8. No errors encountered here.

Update: this seems to specifically affect Ruby 2.3 on Windows. Seems fixed under Ruby 2.4.

@pcai
Copy link
Contributor

pcai commented Jun 7, 2024

Hi - looking at the trace of the original issue, this bug is in rubyntlm and should be addressed in WinRb/rubyntlm#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

@pcai pcai closed this as completed Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants