My first Ruby on Rails commit merged into master

Today my commit was merged into Rails master, yay!

View commit on GitHub

It has to do with a “problem” described by Egor Homakov on his blog. The problem is also described in Rails edge security guide.

The issue can’t really be “fixed” because it’s not really a bug. It’s just that Ruby has different defaults regarding multi-line mode in regular expressions than some other languages. What I did was just let programmers know if they are using the ^ or $ anchors in regular expressions they put into Rails’ validates_format_of. Most likely, they are using them because they copied the RegExp somewhere from the web or they forgot about how Ruby understands these anchors. There is really almost no use case to use ^ or $ in validates_format_of. So this solution is kind of harmless. If you actually do need to use ^ or $, simply add :multiline => true to your format validator, and the exception goes away. But do think first if you really need it, because chances are you want to use A and z.

Advertisements

2 thoughts on “My first Ruby on Rails commit merged into master

  1. Thank you Egor 🙂 I could never have done it if you didn’t discover it. By the way, I arranged so you also get credit in activemodel version history 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s