bf4 / gemproject

Rubygems Project, collecting download stats and meta data on gem releases
https://github.com/bf4/gemproject/issues/1
MIT License
16 stars 5 forks source link

Fix blacklist bug #11

Closed bf4 closed 11 years ago

bf4 commented 11 years ago

See https://github.com/bf4/gemproject/pull/10 and https://twitter.com/hazula/status/396334305313431553

list = ["jordansissel\n", "iconara\n", "michaelklishin\n", "atech\n", "adamcooke\n", "niftyware\n"].map(&:strip)
wrong_regexes = list.map{|username| /#{username}/io }
  # =>  [/jordansissel/i, /jordansissel/i, /jordansissel/i, /jordansissel/i, /jordansissel/i, /jordansissel/i]
correct_regexes = list.map{|username| /#{username}/i }
  # =>  [/jordansissel/i, /iconara/i, /michaelklishin/i, /atech/i, /adamcooke/i, /niftyware/i]

The o flag caused the regex to compile only once, which ignored the other blacklisted usernames