sporkmonger / addressable

Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. It is flexible, offers heuristic parsing, and additionally provides extensive support for IRIs and URI templates.
Apache License 2.0
1.56k stars 265 forks source link

Encoding magic comments are ignored #423

Closed eregon closed 2 years ago

eregon commented 3 years ago

Comments like https://github.com/sporkmonger/addressable/blob/a079a52ba5a5cb43cadd5edaa684ee6874dafaa8/spec/addressable/idna_spec.rb#L3 (and in other files) might be intended as magic comments for Ruby. But they have no effect since they are after a blank line.

You can verify by changing it to # coding: binary, see it changes nothing, but if you move it as first line then specs break as expected.

It probably still works in practice since UTF-8 is the default for recent Rubies.

Unless maybe such comments are purposefully not meant for Ruby and only editors or so?

Noticed while investigating https://github.com/oracle/truffleruby/issues/2408

dentarg commented 3 years ago

Thanks for noticing this. Pretty sure they are meant for Ruby, added as the first line in #33 (link to diff). https://github.com/sporkmonger/addressable/pull/309 added the blank line when adding frozen_string_literal lines.