diff --git a/internal/file/fingerprint.go b/internal/file/fingerprint.go index 81b14f22..d76639c1 100644 --- a/internal/file/fingerprint.go +++ b/internal/file/fingerprint.go @@ -4,7 +4,6 @@ import ( "bufio" "crypto/md5" // #nosec "fmt" - "io" "os" "path/filepath" "strings" @@ -149,19 +148,27 @@ func shouldProcessFile(fileInfo os.FileInfo, exclusions []string, path string) b return true } +func normalizeLineEndings(data []byte) []byte { + // Convert to Unix line endings + return []byte(strings.ReplaceAll(string(data), "\r\n", "\n")) +} + func computeMD5(filename string) (FileFingerprint, error) { - file, err := os.Open(filename) + data, err := os.ReadFile(filename) if err != nil { return FileFingerprint{}, err } - defer file.Close() + + normalizedData := normalizeLineEndings(data) hash := md5.New() // #nosec - if _, err := io.Copy(hash, file); err != nil { + + if _, err := hash.Write(normalizedData); err != nil { return FileFingerprint{}, err } - contentLength, err := file.Seek(0, 2) + contentLength := int64(len(normalizedData)) + if err != nil { return FileFingerprint{}, err }