Skip to content
New issue

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

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

Already on GitHub? # to your account

em_exchange_mark has a possibility to set invalid byte_pointer #794

Open
tompng opened this issue Dec 10, 2024 · 1 comment
Open

em_exchange_mark has a possibility to set invalid byte_pointer #794

tompng opened this issue Dec 10, 2024 · 1 comment

Comments

@tompng
Copy link
Member

tompng commented Dec 10, 2024

Description

  1. Set em_set_mark to non-zero byte_pointer.
    Type A to set byte_pointer to 1 and M-space to set mark to that byte pointer

  2. Edit the input line and make the marked value an invalid value for byte_pointer.
    Type DELETE . valid byte_pointer is 0 or 3.

  3. Type C-x C-x to trigger em_exchange_mark.
    byte_pointer will be an invalid value 1.

irb(main):001> あ/Users/tomoya.ishida/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/reline-0.5.12/lib/reline/unicode.rb:136:in `scan': invalid byte sequence in UTF-8 (ArgumentError)

    rest.scan(WIDTH_SCANNER) do |non_printing_start, non_printing_end, csi, osc, gc|
              ^^^^^^^^^^^^^
	from /Users/tomoya.ishida/.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/reline-0.5.12/lib/reline/unicode.rb:136:in `split_line_by_width'
        ...
        This backtrace is not important. em_exchange_mark sets invalid byte_pointer. Thats all.

Whole input to reproduce is "A\e \C-hあ\C-x\C-x"

Terminal Emulator

Any

@tompng
Copy link
Member Author

tompng commented Dec 15, 2024

GNU Readline has the same problem.

$ irb --readline
irb(main):001> Readline::VERSION
=> "8.2"
irb(main):002> 012345678?i??abcdefg # Inserted `i` between 3-bytes utf-8 character
/path/to/irb/lib/irb/context.rb:637:in `strip': invalid byte sequence in UTF-8 (Encoding::CompatibilityError)

Emacs set_mark seems to remember cursor_column instead of byte_pointer.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

1 participant