Skip to content

Commit

Permalink
Only allow nomination votes if the only lines in the post are nomination
Browse files Browse the repository at this point in the history
references.  Any other text will cause the post to be ignored.
  • Loading branch information
Kinematics committed Aug 12, 2015
1 parent ff05193 commit d43dfc3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion TallyCore/Votes/PostComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class PostComponents : IComparable, IComparer<PostComponents>
readonly Regex allVoteRegex = new Regex(@"^(\s|\[/?[ibu]\]|\[color[^]]+\])*-*\s*\[\s*[xX+✓✔1-9]\s*\].*", RegexOptions.Multiline);
// Nomination-style votes. @username, one per line.
readonly Regex nominationRegex = new Regex(@"^\[url=""[^""]+?/members/\d+/""](?<username>@[^[]+)\[/url\]\s*(?=[\r\n]|$)", RegexOptions.Multiline);
// Regex to extract out all non-whitespace lines from a post's text.
readonly Regex allLinesRegex = new Regex(@"^\s*\S+[^\r\n]*(?=[\r\n]|$)", RegexOptions.Multiline);

/// <summary>
/// Constructor
Expand Down Expand Up @@ -60,7 +62,9 @@ public PostComponents(string author, string id, string text)
matches = nominationRegex.Matches(text);
if (matches.Count > 0)
{
VoteStrings = GetNominationStrings(matches);
MatchCollection allLines = allLinesRegex.Matches(text);
if (allLines.Count == matches.Count)
VoteStrings = GetNominationStrings(matches);
}
}
}
Expand Down

0 comments on commit d43dfc3

Please sign in to comment.