Skip to content

Commit

Permalink
Add segment length check per entry
Browse files Browse the repository at this point in the history
This avoids an IndexError if the length of split segments is shorter than expected.
  • Loading branch information
davemachado committed Apr 21, 2018
1 parent 9bdfc79 commit b756f21
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build/validate_format.py
Expand Up @@ -16,6 +16,7 @@
index_https = 3
index_cors = 4
index_link = 5
num_segments = 6

errors = []
title_links = []
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b756f21

Please sign in to comment.