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

Fix Reline crash with invalid encoding history #751

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

tompng
Copy link
Member

@tompng tompng commented Sep 24, 2024

Fixes #615 and ruby/irb#86

Points:

  • Reline::LineEditor only supports utf8 convertible valid byte sequences.
  • Not all characters are convertible to utf8.
  • Some sjis to utf8 conversion are not reversible.

Comment on lines +62 to +70
converted.gsub(/\X/) do |c|
c.encode(Encoding::UTF_8)
c
rescue Encoding::UndefinedConversionError
'?'
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment?

@tompng tompng force-pushed the history_encoding_safe branch from 232dfcd to a24596d Compare October 1, 2024 16:56
Copy link
Member

@ima1zumi ima1zumi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ima1zumi ima1zumi merged commit e9d4b37 into ruby:master Oct 1, 2024
40 checks passed
@tompng tompng deleted the history_encoding_safe branch October 1, 2024 17:02
@ima1zumi ima1zumi added the bug Something isn't working label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

Reline crash when loading Illegal string encoded differently from the current terminal
2 participants