From f34bf544d3b00d1ec191d458d6c6bc7ed9846cab Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Fri, 6 Nov 2015 13:23:14 -0800 Subject: [PATCH] Update msftidy to flag authors with unbalanced angle brackets --- tools/dev/msftidy.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/dev/msftidy.rb b/tools/dev/msftidy.rb index 68f4eecdf8..19b95e2053 100755 --- a/tools/dev/msftidy.rb +++ b/tools/dev/msftidy.rb @@ -317,6 +317,8 @@ class Msftidy next end + # XXX: note that this is all very fragile and regularly incorrectly parses + # the author # # Mark our 'Author' block # @@ -328,10 +330,12 @@ class Msftidy # - # While in 'Author' block, check for Twitter handles + # While in 'Author' block, check for malformed authors # if in_super and in_author - if line =~ /Author/ + if line =~ /Author['"]\s*=>\s*['"](.*)['"],/ + author_name = Regexp.last_match(1) + elsif line =~ /Author/ author_name = line.scan(/\[[[:space:]]*['"](.+)['"]/).flatten[-1] || '' else author_name = line.scan(/['"](.+)['"]/).flatten[-1] || '' @@ -344,6 +348,14 @@ class Msftidy if not author_name.ascii_only? error("Please avoid unicode or non-printable characters in Author") end + + unless author_name.empty? + author_open_brackets = author_name.scan('<').size + author_close_brackets = author_name.scan('>').size + if author_open_brackets != author_close_brackets + error("Author has unbalanced brackets: #{author_name}") + end + end end end end