> -----Original Message-----
> From: Jeff King
> Sent: Monday, October 16, 2017 6:13 PM
> To: Joris Valette
> Cc: Andreas Schwab; Jason Pyeron; [email protected]
> Subject: Re: Consider escaping special characters like 'less' does
>
<snip/>
>
> I.e., something like this would probably help your case
> without hurting
> anybody:
>
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index 28b325d754..d44e5ea459 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -714,6 +714,16 @@ sub parse_diff {
> push @{$hunk[-1]{DISPLAY}},
> (@colored ? $colored[$i] : $diff[$i]);
> }
> +
> + foreach my $hunk (@hunk) {
> + foreach my $line (@{$hunk->{DISPLAY}}) {
> + # all control chars minus newline and
> ESC (for color)
> + if ($line =~ s/[\000-\011\013-\032\034-\037]/?/g) {
What about CR [0x0D] ?
> + $hunk->{CONTROLCHARS} = 1;
> + }
> + }
> + }
> +
> return @hunk;
> }
>
> @@ -1407,6 +1417,9 @@ sub patch_update_file {
> if ($hunk[$ix]{TYPE} eq 'hunk') {
> $other .= ',e';
> }
> + if ($hunk[$ix]->{CONTROLCHARS}) {
> + print "warning: control characters in
> hunk have been replaced by '?'\n";
> + }
> for (@{$hunk[$ix]{DISPLAY}}) {
> print;
> }
>
> I can't help but feel this is the tip of a larger iceberg,
> though. E.g.,
> what about characters outside of the terminal's correct encoding? Or
> broken UTF-8 characters?
>
> -Peff
>