Check that metadata rating is between 0 and 5

Does not handle Rating=-1 meaning Rejected yet.
This commit is contained in:
Eric Jiang
2019-05-16 19:37:27 -07:00
parent 820024972a
commit a25655cafd

View File

@@ -200,6 +200,16 @@ FrameData::FrameData (rtexif::TagDirectory* frameRootDir_, rtexif::TagDirectory*
if (newFrameRootDir->getXMPTagValue("xmp:Rating", sXMPRating)) {
rating = atoi(sXMPRating);
}
// guard against out-of-range values
if (rating > 5) {
rating = 5;
}
// Currently, Rating=-1 is not supported. A value of -1 should mean
// "Rejected" according to the specification. Maybe in the future, Rating=-1
// sets InTrash=true?
if (rating < 0) {
rating = 0;
}
tag = newFrameRootDir->findTagUpward("MakerNote");
rtexif::TagDirectory* mnote = nullptr;