Page MenuHomeFreeBSD

nvi: fallback to iso8859-1 if utf-8 check failed and fileencoding/locale encoding is utf-8
AcceptedPublic

Authored by yuripv on Tue, May 19, 5:00 PM.

Details

Summary

Trying to use the user locale's encoding that is UTF-8 doesn't make much sense if we already know that it fail as we failed the looks_utf8() check above. I've changed the logic to fallback to ISO8859-1 instead as it seems to be the most widely used single byte locale:

  1. Check for valid UTF-8.
  2. Check if fallback fileencoding is set and is NOT UTF-8.
  3. Check if user locale's encoding is NOT UTF-8.
  4. Use ISO8859-1 as last resort.

Triggered by a question from Ronald F. Guilmette on questions@.

Test Plan

Having any UTF-8 locale (e.g. en_US.UTF-8), try editing a file with (valid) ISO8859-1 characters in [128,255] bytes range:

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

yuripv created this revision.Tue, May 19, 5:00 PM
yuripv requested review of this revision.Tue, May 19, 5:00 PM
bapt added a comment.Tue, May 19, 5:03 PM

Have you contacted the upstream? https://github.com/lichray/nvi2

In D24919#548529, @bapt wrote:

Have you contacted the upstream? https://github.com/lichray/nvi2

Will do, forgot about it! Thanks.

In D24919#548529, @bapt wrote:

Have you contacted the upstream? https://github.com/lichray/nvi2

Will do, forgot about it! Thanks.

As I have pretty limited connectivity at the moment and can't do a pull request, I'm adding to author to this review. If it doesn't work out, I'll send a PR in few days.

I agree with the change. Please send a PR later, thanks.

contrib/nvi/common/exf.c
13

If you must commit this, please bump the revision (to 10.65), update the date, and put "yuripv" in place of "zy" so that ident(1) can tell users what behavior they should expect from their binary.

This revision is now accepted and ready to land.Wed, May 20, 2:36 AM