Skip to content

Commit

Permalink
Make sure to clean the vote of markup before trying to run the regex to
Browse files Browse the repository at this point in the history
see if it's a vote line. Simplifies vote line check.
  • Loading branch information
Kinematics committed Oct 23, 2015
1 parent 0740179 commit 42e466c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions TallyCore/Votes/PostComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class PostComponents : IComparable, IComparer<PostComponents>
// A post with ##### at the start of one of the lines is a posting of tally results. Don't read it.
readonly Regex tallyRegex = new Regex(@"^#####", RegexOptions.Multiline);
// A valid vote line must start with [x] or -[x] (with any number of dashes). It must be at the start of the line.
readonly Regex voteLineRegex = new Regex(@"^(\s|\[/?[ibu]\]|\[color[^]]+\])*-*\s*\[\s*[xX+✓✔1-9]\s*\]");
readonly Regex voteLineRegex = new Regex(@"^-*\s*\[\s*[xX+✓✔1-9]\s*\]");
// Nomination-style votes. @username, one per line.
readonly Regex nominationLineRegex = new Regex(@"^\[url=""[^""]+?/members/\d+/""](?<username>@[^[]+)\[/url\]\s*$");

Expand All @@ -50,7 +50,7 @@ public PostComponents(string author, string id, string text)
return;

var lines = Utility.Text.GetStringLines(text);
var voteLines = lines.Where(a => voteLineRegex.Match(a).Success);
var voteLines = lines.Where(a => voteLineRegex.Match(VoteString.CleanVote(a)).Success);

if (voteLines.Any())
{
Expand Down

0 comments on commit 42e466c

Please sign in to comment.