Skip to content

Encoding of input file is not respected #645

Open
@voxik

Description

@voxik

I wonder what was the intention of #528? I am asking since this fails:

$ LC_ALL=cs_CZ.ISO-8859-2 rspec ./spec/actions/inject_into_file_spec.rb:107
Run options: include {:locations=>{"./spec/actions/inject_into_file_spec.rb"=>[107]}}
F

Failures:

  1) Thor::Actions::InjectIntoFile#invoke! can insert chinese
     Failure/Error: if force || !content.include?(replacement)
     
     Encoding::CompatibilityError:
       incompatible character encodings: ISO-8859-2 and UTF-8
     # ./lib/thor/actions/inject_into_file.rb:102:in `include?'
     # ./lib/thor/actions/inject_into_file.rb:102:in `replace!'
     # ./lib/thor/actions/inject_into_file.rb:57:in `invoke!'
     # ./lib/thor/actions.rb:94:in `action'
     # ./lib/thor/actions/inject_into_file.rb:27:in `insert_into_file'
     # ./spec/actions/inject_into_file_spec.rb:20:in `block in invoke!'
     # ./spec/helper.rb:55:in `capture'
     # ./spec/actions/inject_into_file_spec.rb:20:in `invoke!'
     # ./spec/actions/inject_into_file_spec.rb:108:in `block (3 levels) in <top (required)>'

Finished in 0.01246 seconds (files took 0.31693 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/actions/inject_into_file_spec.rb:107 # Thor::Actions::InjectIntoFile#invoke! can insert chinese

Previously, if nothing else, the encoding of File.binread was given. Now it gets a file of unknown encoding, tries to apply system encoding and do some stuff above it. If the encoding is assumed, then it should be probably specified somewhere or there should be done a conversion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions