Strip quotes off EXIF values before they go into the database

This commit is contained in:
Eli Ribble 2026-03-09 22:10:40 +00:00
parent 93d767c9d6
commit 2071ae9e54
No known key found for this signature in database

View file

@ -170,10 +170,11 @@ func saveImageUploads(ctx context.Context, tx bob.Tx, uploads []ImageUpload) (mo
exif_setters := make([]*models.PublicreportImageExifSetter, 0)
for k, v := range u.Exif.Tags {
to_save := trimQuotes(v)
exif_setters = append(exif_setters, &models.PublicreportImageExifSetter{
ImageID: omit.From(image.ID),
Name: omit.From(k),
Value: omit.From(v),
Value: omit.From(to_save),
})
}
if len(exif_setters) > 0 {
@ -190,3 +191,11 @@ func saveImageUploads(ctx context.Context, tx bob.Tx, uploads []ImageUpload) (mo
}
return images, nil
}
// Given a string like "\"foo\"" return "foo".
func trimQuotes(s string) string {
if len(s) >= 2 && s[0] == '"' && s[len(s)-1] == '"' {
return s[1 : len(s)-1]
}
return s
}