Skip to content

Fix Reline crash with invalid encoding history#751

Merged
ima1zumi merged 1 commit into
ruby:masterfrom
tompng:history_encoding_safe
Oct 1, 2024
Merged

Fix Reline crash with invalid encoding history#751
ima1zumi merged 1 commit into
ruby:masterfrom
tompng:history_encoding_safe

Conversation

@tompng

@tompng tompng commented Sep 24, 2024

Copy link
Copy Markdown
Member

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 thread lib/reline/unicode.rb
Comment on lines +62 to +70
converted.gsub(/\X/) do |c|
c.encode(Encoding::UTF_8)
c
rescue Encoding::UndefinedConversionError
'?'
end

Copy link
Copy Markdown
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

@ima1zumi ima1zumi left a comment

Copy link
Copy Markdown
Member

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
@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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants