From 0e34dfa4ec24ad749db5f81d3af6fae148e7ce5d Mon Sep 17 00:00:00 2001 From: eric bryant Date: Fri, 12 Jun 2020 19:32:43 -0400 Subject: [PATCH] invalid char datacheck improvements * Python: prevent crash when entire label is asterisks * C++: flag error when label == "*" --- siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp | 8 ++++++-- siteupdate/python-teresco/siteupdate.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp b/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp index 078d91d1..9ec0d0fc 100644 --- a/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp +++ b/siteupdate/cplusplus/classes/Waypoint/Waypoint.cpp @@ -406,13 +406,17 @@ inline void Waypoint::label_looks_hidden(DatacheckEntryList *datacheckerrors) inline void Waypoint::label_invalid_char(DatacheckEntryList *datacheckerrors) { // look for labels with invalid characters - for (const char *c = label.data(); *c; c++) + if (label == "*") + datacheckerrors->add(route, label, "", "", "LABEL_INVALID_CHAR", ""); + else for (const char *c = label.data(); *c; c++) if ((*c == 42 || *c == 43) && c > label.data() || (*c < 40) || (*c == 44) || (*c > 57 && *c < 65) || (*c == 96) || (*c > 122) || (*c > 90 && *c < 95)) datacheckerrors->add(route, label, "", "", "LABEL_INVALID_CHAR", ""); for (std::string& lbl : alt_labels) - for (const char *c = lbl.data(); *c; c++) + if (lbl == "*") + datacheckerrors->add(route, lbl, "", "", "LABEL_INVALID_CHAR", ""); + else for (const char *c = lbl.data(); *c; c++) if (*c == '+' && c > lbl.data() || *c == '*' && (c > lbl.data()+1 || lbl[0] != '+') || (*c < 40) || (*c == 44) || (*c > 57 && *c < 65) || (*c == 96) || (*c > 122) || (*c > 90 && *c < 95)) diff --git a/siteupdate/python-teresco/siteupdate.py b/siteupdate/python-teresco/siteupdate.py index fc55b6f5..55668533 100755 --- a/siteupdate/python-teresco/siteupdate.py +++ b/siteupdate/python-teresco/siteupdate.py @@ -3936,7 +3936,7 @@ def run(self): # look for labels with invalid first or last character index = 0 - while w.label[index] == '*': + while index < len(w.label) and w.label[index] == '*': index += 1 if index < len(w.label) and w.label[index] in "_/(": datacheckerrors.append(DatacheckEntry(r,[w.label],'INVALID_FIRST_CHAR', w.label[index]))