parameter validation for title, text_top, and text_bottom in app/models/...#69
parameter validation for title, text_top, and text_bottom in app/models/...#69josephzang wants to merge 1 commit intoOpenHackIC:masterfrom josephzang:master
Conversation
…ls/captioned_image.rb
|
I don't understand this PR. Firstly, its implementation allows only single characters: irb> expr = %r{\A[A-Za-z0-9 _-?!]\Z}
irb> expr.match("hello")
nil
irb> expr.match("h")
0Secondly, why restrict input at all? What if a Russian or Mexican or French Canadian animal shelter wants to use the app? What about a Chinese one? What if a user wants to put a ☺ in their caption? If anything we might validate to only accept printable characters, but otherwise I don't see a reason to restrict what characters users can put in their images. |
|
Thanks for the contribution @josephzang. @jrunning has a point, it probably doesn't make sense to restrict input too much. However, if the API we're using doesn't work with certain character ranges, it could make sense. |
|
Oh jeez. Sorry about that. I can't even run it in irb -- the ?! and space break it. I forgot the asterisk at the end to let it match zero or many characters, and I didn't consider the language thing. I obviously didn't test it, but that's partly because I wasn't able to get the heroku-cedar box to boot in vagrant, even after deleting and redownloading the file from dropbox a few times. Do either of you have any ideas? |
|
The Vagrant box isn't entirely necessary, just maybe easier in a "repeatable" kind of way. It's known not to work that well with Windows. If you can get Ruby, etc running on your machine, that can work just fine as well. I'd look into |
|
I'm on Ubuntu 12.04 and had vagrant running the precise32 box in the docs, but oh well I guess. I do have an environment set up with RVM, but I don't have PostgreSQL installed. I suppose I'll do that then -- vagrant looked really cool is all. |
|
It should work fine on Ubuntu 12.04... that's what I'm running. The instructions in the README are exactly what I ran to test it. Note that you might need a newer version of Vagrant. The one in the Ubuntu repositories for 12.04 is ancient. I can maybe walk you through it sometime too, if you'd like. :) |
...captioned_image.rb