diff options
Diffstat (limited to 'internal/gitaly/service/repository/raw_changes.go')
-rw-r--r-- | internal/gitaly/service/repository/raw_changes.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/gitaly/service/repository/raw_changes.go b/internal/gitaly/service/repository/raw_changes.go index fb1c2c5a1..3f59f5f89 100644 --- a/internal/gitaly/service/repository/raw_changes.go +++ b/internal/gitaly/service/repository/raw_changes.go @@ -6,6 +6,7 @@ import ( "io" "regexp" "strconv" + "unicode/utf8" "gitlab.com/gitlab-org/gitaly/v14/internal/git" "gitlab.com/gitlab-org/gitaly/v14/internal/git/catfile" @@ -164,6 +165,10 @@ func changeFromDiff(ctx context.Context, objectInfoReader catfile.ObjectInfoRead return resp, nil } +// InvalidUTF8PathPlaceholder is a temporary placeholder that indicates the +const InvalidUTF8PathPlaceholder = "ENCODING ERROR gitaly#1470" + +//nolint:staticcheck func setOperationAndPaths(d *rawdiff.Diff, resp *gitalypb.GetRawChangesResponse_RawChange) error { if len(d.Status) == 0 { return fmt.Errorf("empty diff status") @@ -193,5 +198,15 @@ func setOperationAndPaths(d *rawdiff.Diff, resp *gitalypb.GetRawChangesResponse_ resp.Operation = gitalypb.GetRawChangesResponse_RawChange_UNKNOWN } + resp.OldPath = string(resp.OldPathBytes) + resp.NewPath = string(resp.NewPathBytes) + + if !utf8.ValidString(resp.OldPath) { + resp.OldPath = InvalidUTF8PathPlaceholder + } + if !utf8.ValidString(resp.NewPath) { + resp.NewPath = InvalidUTF8PathPlaceholder + } + return nil } |