Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stripDateError() crash and never emit empty date@isodate. #3548

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/iohumdrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3064,6 +3064,10 @@ std::map<std::string, std::string> HumdrumInput::isoDateAttributesFromHumdrumDat
std::vector<std::string> isodates;
for (auto const &date : dates) {
std::string isodate = isoDateFromDateWithErrors(date, edtf);
if (isodate.empty()) {
// date not representable as isodate; bail on all isodates for this piece of metadata
return attribs;
}
isodates.push_back(isodate);
}

Expand Down Expand Up @@ -3410,8 +3414,17 @@ std::string HumdrumInput::stripDateError(std::string &value)
if (idx == SIZE_MAX) {
return "";
}
char errorStr[1];
errorStr[0] = value[idx];
std::string errorStr;
if (value[idx] == '?') {
// we have to escape it (twice) to put it in a regex
errorStr = "\\?";
}
else {
char chars[2];
chars[0] = value[idx];
chars[1] = 0;
errorStr = chars;
}

hum::HumRegex hre;
hre.replaceDestructive(value, "", errorStr);
Expand Down