From b756f21f13fccb4a3e3b7f3db75e7107882ce5fd Mon Sep 17 00:00:00 2001 From: Dave Machado Date: Sat, 21 Apr 2018 14:22:41 -0400 Subject: [PATCH] Add segment length check per entry This avoids an IndexError if the length of split segments is shorter than expected. --- build/validate_format.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/validate_format.py b/build/validate_format.py index 0dafd6db..e59daa0b 100755 --- a/build/validate_format.py +++ b/build/validate_format.py @@ -16,6 +16,7 @@ index_auth = 2 index_https = 3 index_cors = 4 index_link = 5 +num_segments = 6 errors = [] title_links = [] @@ -133,6 +134,10 @@ def check_format(filename): continue num_in_category += 1 segments = line.split('|')[1:-1] + if len(segments) < num_segments: + add_error(line_num, "entry does not have all the required sections (have {}, need {})".format( + len(segments), num_segments)) + continue # START Global for segment in segments: # every line segment should start and end with exactly 1 space