diff --git a/course/content.py b/course/content.py index 5c7e8bd3a0412dc4a5048b33b3541d39de63fcf2..407d1adadbfbb2730847d9917044a40141b3049e 100644 --- a/course/content.py +++ b/course/content.py @@ -579,6 +579,9 @@ def get_raw_yaml_from_repo(repo, full_name, commit_sha): return result +LINE_HAS_INDENTING_TABS_RE = re.compile("^\s*\t\s*", re.MULTILINE) + + def get_yaml_from_repo(repo, full_name, commit_sha, cached=True): # type: (Repo_ish, Text, bytes, bool) -> Any @@ -605,10 +608,16 @@ def get_yaml_from_repo(repo, full_name, commit_sha, cached=True): if result is not None: return result + yaml_bytestream = get_repo_blob( + repo, full_name, commit_sha, allow_tree=False).data + yaml_text = yaml_bytestream.decode("utf-8") + + if LINE_HAS_INDENTING_TABS_RE.search(yaml_text): + raise ValueError("File uses tabs in indentation. " + "This is not allowed.") + expanded = expand_yaml_macros( - repo, commit_sha, - get_repo_blob(repo, full_name, commit_sha, - allow_tree=False).data) + repo, commit_sha, yaml_bytestream) result = dict_to_struct(load_yaml(expanded)) diff --git a/course/validation.py b/course/validation.py index 06c4f644c09f8493e62315754194d52ed840aa53..27ed619cc17b25ab4918ca7e6fc4965d138a7def 100644 --- a/course/validation.py +++ b/course/validation.py @@ -1512,11 +1512,11 @@ def validate_course_content(repo, course_file, events_file, )) % entry_path) - location = "staticpages/%s" % entry_path - page_desc = get_yaml_from_repo_safely(repo, location, - commit_sha=validate_sha) + location = "staticpages/%s" % entry_path + page_desc = get_yaml_from_repo_safely(repo, location, + commit_sha=validate_sha) - validate_staticpage_desc(vctx, location, page_desc) + validate_staticpage_desc(vctx, location, page_desc) # }}}