Skip to content

String#encode replace option incorrectly handles value #8872

@headius

Description

@headius

The following example should simply clear bad bytes during encode. Instead, it tries to call [] on the empty string, thinking that it is a function to handle the error.

$ jruby -e 'p "foo\xFF".force_encoding("ASCII-8BIT").encode("US-ASCII", replace: "")'
NoMethodError: undefined method '[]' for nil
  encode at org/jruby/RubyString.java:6844
  <main> at -e:1

We clearly aren't handling the :replace option right here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions