The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-01-19

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:07 Gedge joined #mojo
00:26 noganex joined #mojo
00:26 Adura joined #mojo
00:26 Gedge joined #mojo
00:28 berov1 joined #mojo
00:29 Ralesk joined #mojo
00:34 Kogurr joined #mojo
01:05 sri a few days ago i found a bug in mojolicious, but i was too tired to fix it and went to sleep instead... now i can't remember what it was :S
01:25 genio jberger: bwahaha  https://www.youtube.com/watch?v=G7oGx2dImE8
01:28 jberger Oo
01:28 genio you're welcome
01:28 * genio takes a bow
01:30 genio I can't stop listening to it though
02:06 henq joined #mojo
02:12 henq er….    is it too crazy to desire this to Just Work?  get ‘/:action/:id/?foo=:foo&t=bar=:bar’
02:12 henq the query parameters foo and bar to end up in the stash automagically?  (I suspect it’s now wise to want that… )
02:12 bpmedley joined #mojo
02:13 Grinnz henq, you can get them all with $c->param anyway
02:13 henq Ohh, then I must have made another fault, b/c that I tried first. Thx
02:14 Grinnz not including the query string in the route that is
02:16 henq ahhh. pfff.   should not code after 02:00am ....
02:20 henq Mojo is always even more automagical than one thinks…. ;-)
02:48 inokenty-w joined #mojo
03:20 binlei joined #mojo
03:48 noganex_ joined #mojo
04:17 c--__ joined #mojo
06:27 kes joined #mojo
06:30 Vandal joined #mojo
07:20 Gedge_ joined #mojo
07:21 absolut_todd joined #mojo
07:39 salva joined #mojo
08:08 osfabibisi joined #mojo
08:19 trone joined #mojo
08:23 AndrewIsh joined #mojo
08:33 abra joined #mojo
08:43 kivilahtio joined #mojo
09:07 odc joined #mojo
09:16 binlei joined #mojo
09:31 binlei joined #mojo
09:48 melo joined #mojo
09:51 punter joined #mojo
09:54 jontaylor joined #mojo
10:46 sue joined #mojo
11:56 neilhwatson joined #mojo
12:16 sue joined #mojo
12:37 punter joined #mojo
12:52 sue joined #mojo
12:54 cpan_mojo Mojo-Webqq-1.7.0 by SJDY https://metacpan.org/release/SJDY/Mojo-Webqq-1.7.0
13:08 dod joined #mojo
13:09 zivester joined #mojo
13:32 ajr_ joined #mojo
13:33 binlei joined #mojo
13:34 binlei joined #mojo
13:38 dod1 joined #mojo
13:51 dod joined #mojo
14:16 mib_nwd2wv joined #mojo
14:17 mullagain joined #mojo
14:18 mib_nwd2wv When rendering, does mojolicous convert all " to "? Apparently, this is happening. If not, I cannot see anywhere in my code where I am doing this conversion myself, so I think mojo is doing it. Is there a way to prevent it? If not, how can I pass html code?
14:19 Grinnz mib_nwd2wv, are you using EP templates?
14:19 mib_nwd2wv I don't know
14:19 Grinnz https://metacpan.org/pod/Mojo::Template#SYNTAX
14:20 mib_nwd2wv I create a mojo app (not lite) and am using that as a starting point
14:22 mib_nwd2wv *created
14:22 Grinnz theres no automatic escaping done in the render step, so it's either a template or something else
14:25 mib_nwd2wv I don't see use Mojo::Template; being invoked anywhere. What is the default template? Is there one?
14:26 mib_nwd2wv Obviously, the template renders, but what if use Mojo::Template; is not called? Apparently it still works.
14:26 Grinnz EP https://metacpan.org/pod/Mojolicious::Guides::Rendering#Embedded-Perl
14:26 Grinnz it's the default handler of the Mojolicious::Renderer, and used for templates ending in .ep
14:28 mib_nwd2wv So use Mojo::Template behaves differently? Or is the same? Which one is preferred?
14:29 Grinnz no need to use it yourself, the EP handler already uses it
14:29 Grinnz https://metacpan.org/pod/Mojolicious::Plugin::EPRenderer
14:29 mib_nwd2wv OK. So it's the default. Thanks. I've checked my code through and I don't see anywhere where " is being converted to " .... that's because I use " and not " in my conversions. So something that is converting it ... and I don't get this conversion when I do not use Mojo.
14:30 Grinnz are you using templates or not?
14:30 Grinnz they either come from data sections or files
14:30 mib_nwd2wv as mentioned, I create an app (not lite) and it does use a template, yes
14:30 Grinnz (or inline)
14:31 mib_nwd2wv but I'm not using Mojo::Template, so my understanding based on what you have written is that it is called anyway
14:31 Grinnz does the template use that syntax to embed the variable?
14:32 mib_nwd2wv It's just the default template from create a new app (see attached)
14:32 Grinnz from the earlier link in the guide, you can see that <%= will escape the expression and <%== will not
14:32 mib_nwd2wv http://mibpaste.com/LVcZUd
14:32 Grinnz so if you are manually escaping the expression beforehand, you want to use <%==
14:33 mib_nwd2wv I'm calling this up as follows (see attached)
14:33 mib_nwd2wv http://mibpaste.com/ntVU9u
14:33 mib_nwd2wv So if you see <%= $main %> in that last past, then all of that stuff is getting converted
14:33 mib_nwd2wv OK So that's it.
14:34 mib_nwd2wv Thanks.
14:34 mib_nwd2wv Hey that's a pretty cool feature.
14:34 mib_nwd2wv Thanks for helping out.
14:34 mib_nwd2wv One more among the myriad of info that I did not catch get (I'm getting there)
14:34 Grinnz sure, just be careful that you don't use <%== for something unless you're sure it's escaped, or really sure it doesn't need to be
14:35 mib_nwd2wv right
14:35 mib_nwd2wv thanks.
14:36 Grinnz it helps to read the guides a few times, it's easy to miss stuff the first time through (I still happen on a few things I missed)
14:36 mib_nwd2wv yes, I'm just getting into it. I've read a fair amount of the docs. Will keep reading. Thank you.
15:02 kaare joined #mojo
15:05 ZoffixW joined #mojo
15:10 ZoffixW Curious, did it ever happen to anyone that two apps hosted on the same box would somehow get crossed over? I have two similar apps (one is a modified copy of the other). They handle subscribers and send confirmation emails with a link to different subdomains. The link contains a JWT token. When that link is clicked, both apps send a another email. Yesterday, I used my go-green.FOO.ca app to generate the email with the link, but when I
15:10 ZoffixW clicked it (and it's a http://go-green... link), the email arrived as if it were from my email.FOO.ca app. A few more attempts at reproducing it yielded nothing, but we announced our go-green app to customers (but not the other one), yet about 5% of notifications emails I'm getting are from the unannounced app, which makes me think the bug is still there. Here's my Apache config FWIW: http://fpaste.scsys.co.uk/504468
15:17 ZoffixW Maybe I'm just going insane :) I don't see how it could be possible at all, since there are two SQLite databases and the second email is not sent if the entry is missing in the db :")
15:19 pink_mist since you copied it, I'd guess you missed some change needed ...
15:19 ZoffixW But wouldn't those missed changes affect every entry and not just once in a blue moon?
15:19 ZoffixW It's worth noting, the app has 98% test coverage and all tests pass.
15:19 pink_mist I couldn't tell from this end of the conversation.
15:20 ZoffixW And databases have different number of fields.
15:23 vicash ZoffixW: use wireshark and check where the link's requests are going. then go step by step to figure out why a request is being handled by the wrong app. maybe the subdomain DNS request is not working right. maybe your app is fine...
15:24 Kogurr joined #mojo
15:24 vicash if you're worried which database is being opened, run strace on the apps and see which databases are being opened by each app ..
15:24 jberger ZoffixW: <proxy *>
15:24 jberger ?
15:24 jberger I don't know apache proxies at all, but that makes me wonder
15:24 jberger http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxy
15:24 abra_ joined #mojo
15:25 ZoffixW Here's my Go Green app's controller/model http://fpaste.scsys.co.uk/504471  and here's the Email subdomain app http://fpaste.scsys.co.uk/504472
15:26 ZoffixW vicash, wiresharking is problematic since I can obviously see the request is going to the right place with my browser.
15:27 ZoffixW jberger, seems OK to me.
15:28 jberger but if both apps match all requests then wouldn't it proxy to both apps?
15:28 vicash ZoffixW:  try making the link request without using the Apache proxying. you have to remove each layer to make sure it is not the DNS proxying that is the problem rather than the app.
15:29 dragos joined #mojo
15:30 ZoffixW jberger, but since that's inside the VirtualHost config for a particular domain, wouldn't that apply first?
15:30 jberger that's not how I read that directive's docs
15:30 jberger I mean, yes, its what I would have expected, but seeing as that's the problem you are experiencing ...
15:33 ZoffixW k, I commented out the <proxy *> ... </proxy> stuff altogether now.
15:34 ZoffixW vicash, good plan.
15:48 good_news_everyon joined #mojo
15:48 good_news_everyon [mojo] jberger pushed 1 new commit to master: https://github.com/kraih/mojo/commit/406d28e3d1278751816886a51eb5714f4c0436d6
15:48 good_news_everyon mojo/master 406d28e Joel Berger: need to import dumper for debug output
15:48 good_news_everyon left #mojo
15:53 sue joined #mojo
15:54 ZoffixW I think I'll rule on the "Maybe I'm just going insane" option... Even if there are proxy issues, I don't see how it'd be possible for App 1 to add an entry into App 2's DB, while sending an App 1 email (the code for both is in one sub) and then have the generated App 1's link look up App 2's DB and send App 2's email. :)
15:55 ZoffixW I added <!-- <%= url_for('/')->to_abs->to_string %> -->  into the template for the App 2's email and just gonna wait and see if it's generated from the wrong domain the next time I get a weird email
15:55 ZoffixW Thanks for help all \o
15:55 vicash ZoffixW: maybe the best option is to move the App1 and App2 on to separate VMs and see where the apps break trying to find your SQLite db
15:56 jberger ZoffixW: good luck
15:57 ZoffixW vicash, one of the apps will exist only until Feb 15, and I still have all the emails of customers. So worst case is I just email them all asking for additional info :)
15:57 ZoffixW I think I'll leave this for now, but thanks for the suggestion.
16:00 zivester joined #mojo
16:25 sh4 joined #mojo
16:30 sri wow, the new rails logo is so ugly
16:36 zivester joined #mojo
16:37 good_news_everyon joined #mojo
16:37 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://github.com/kraih/mojo/commit/318770ba8d8b9a645af6a0b6ea687879ab318b95
16:37 good_news_everyon mojo/master 318770b Sebastian Riedel: update Changes
16:37 good_news_everyon left #mojo
16:54 ajr_ joined #mojo
17:00 jberger sri / others: I'm trying to test my tcp<->websocket relay by connecting it to a simple tcp echo server
17:00 jberger the test hangs right after the first message is sent on the websocket
17:01 jberger is there some obvious thing I need to do to make a server be non-blocking or something/
17:01 jberger ?
17:04 pink_mist make it using an async framework like IO::Async?
17:05 pink_mist https://metacpan.org/source/PEVANS/IO-Async-0.70/examples/echo-server.pl
17:06 sri jberger: no, there should be quite a few in the core tests
17:06 sri pink_mist: what does that gain you over Mojo::IOLoop?
17:06 jberger sri: yeah, I've been reading through them
17:07 pink_mist sri: I'm not used to building async servers from scratch using mojo stuff, so I use what I already know
17:07 jberger my best guess is that I'm hanging here: https://github.com/kraih/mojo/blob/master/lib/Test/Mojo.pm#L272-L273
17:12 dragos sri: Hi, quite new here, just wanted to ask if you know why the search on mojolio.us (powered by Google) now returns weird results, most of which direct me to source files?
17:13 dragos sri: Sorry meant mojolicious.org*
17:21 zivester joined #mojo
17:32 HtbaaPi joined #mojo
17:32 sri jberger: unlikely
17:33 jberger I can see the websocket debug message written but I don't see the websocket server receive it
17:34 sri dragos: should be fixed
17:35 sri about 70 stickers sold now \o/
17:35 sri interesting how so many people just pick one kind of sticker
17:37 sri 65% raptors
17:38 * sri would like to see some pictures on twitter :)
17:51 ssm joined #mojo
18:02 PryMar56 joined #mojo
18:06 mib_nwd2wv Correct me if I'm wrong but mojolicious is persistent, unless cgi that is non-persistent is that correct? The reason I'm asking is that I have an include file with global hash "$n" and in CGI it's initialized each time, but in mojo it appears to already be initialized and indeed any state that was set is remembered on the web page being accessed.
18:06 mib_nwd2wv * unless in previous line should be *unlike
18:07 jberger mib_nwd2wv: yes Mojolicious is persistent
18:08 trone joined #mojo
18:08 jberger in places that you might have used a global, best to store state in the controller's stash
18:09 jberger which is just a per-request hashref that accompanies the request all the way through its lifecyc;e
18:11 mib_nwd2wv I guess stash is for scalar values only?
18:11 jberger its just a hashref, put anything in it you want
18:11 mib_nwd2wv OK, well, that's great.
18:12 jberger http://mojolicious.org/perldoc/Mojolicious/Controller#stash
18:12 jberger note that there are some reserved values which control things about the response
18:12 jberger the stash is really central to everything in a mojo req-res cycle
18:12 * genio ponders a bittorrent client with Mojo
18:13 mib_nwd2wv So can I do this? $c->stash({foo => ['yellow','brown','red']})
18:14 mib_nwd2wv Or this? $c->stash({foo => { a=>1,b=>2}})
18:17 sri literally in the guides
18:17 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Stash-data
18:20 mib_nwd2wv OK that's pretty clear. One more question ... can I add multiple values simultaneously? eg. $c->stash(spinoffs    => {minion => 'job queue'}, hello => 'yes');  (I don't see that example)
18:20 mib_nwd2wv I mean, it kind of looks like an array of hashes that way, but is it?
18:21 mib_nwd2wv actually, nix that. that's not true.
18:21 mib_nwd2wv So I'm assuming I can add just one lval at a time.
18:30 good_news_everyon joined #mojo
18:30 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://github.com/kraih/mojo/commit/48c4243c5e8b0e6324d9643a0f510647f61b54f1
18:30 good_news_everyon mojo/master 48c4243 Sebastian Riedel: no need to use qw() in examples
18:30 good_news_everyon left #mojo
18:38 good_news_everyon joined #mojo
18:38 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://github.com/kraih/mojo/commit/d773a43696d36187e683811bcfc37fbb9cad1491
18:38 good_news_everyon mojo/master d773a43 Sebastian Riedel: more stash examples
18:38 good_news_everyon left #mojo
18:48 dod joined #mojo
19:01 disputin joined #mojo
19:12 jberger sri: in my testing I'm getting a warning because of this, what do you think of just adding something to suppress a warning? http://paste.debian.net/366684/
19:12 disputin joined #mojo
19:12 dragos sri: Can confirm it is fixed. Cheers.
19:13 sri jberger: seems reasonable
19:13 jberger does it need tests?
19:14 sri yes
19:14 * jberger ponders
19:14 jberger test that it works with the change or test that it doesn't emit a warning?
19:14 jberger the former I'd assume
19:15 * sri nods
19:19 jberger mention in Changes?
19:19 sri too unimportant
19:20 jberger I thought so too
19:22 good_news_everyon joined #mojo
19:22 good_news_everyon [mojo] jberger pushed 1 new commit to master: https://github.com/kraih/mojo/commit/6a7e55e75d2bdf38c58b19b89bd97a473b25a423
19:22 good_news_everyon mojo/master 6a7e55e Joel Berger: prevent a warning if a websocket protocol is not requested
19:22 good_news_everyon left #mojo
19:33 good_news_everyon joined #mojo
19:33 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://github.com/kraih/mojo/commit/ae07f91e262675c4b1b9e3bf8ff622a4fadce428
19:33 good_news_everyon mojo/master ae07f91 Sebastian Riedel: "0" is also a valid subprotocol
19:33 good_news_everyon left #mojo
19:34 jberger sri++ good catch
19:34 sri my first instinct nowadays when i see a ||
19:34 sri :)
19:35 Grinnz "is 0 or empty string valid? damn, now this is going to be annoying on 5.8"
19:35 Grinnz :P
19:36 sri empty string is not
19:36 sri you need a "token" as defined in rfc 2616
19:37 jberger Grinnz: it handles empty string correctly already, there was just a warning from split if there was no string at all in the header
19:37 Grinnz it won't be caught by that split anyway
19:37 Grinnz i mean, returned
19:37 Grinnz right
19:50 mib_nwd2wv wow. is that a speedup of about 150x that I see with mojo? It's a lot faster than plain old cgi
19:50 mib_nwd2wv I'm seriously getting some amazing results.
19:52 osfameron mib_nwd2wv: that's quite common when you move from CGI to a persistent server
19:52 osfameron it's a rather lovely feeling :-)
19:52 mib_nwd2wv yeah, it's like, incredible.
19:52 mib_nwd2wv it looks like I can throw away my old code that used convert them all to static html pages :-)
19:52 osfameron I had that the first time moving from CGI to Apache mod_perl ;-)
19:53 osfameron (I don't recommend that at all of course these days ;-)
19:53 mib_nwd2wv I'm really blown away by the speed
19:53 mib_nwd2wv it's like ... lightning
19:54 mib_nwd2wv (what I've always wanted, but could somehow never achieve ... not even close)
20:03 pink_mist yep, switching to modern ways of doing things are often worth the effort =) (though there are exceptions *cough*systemd*cough*)
20:03 asarch joined #mojo
20:03 Grinnz that's worth the effort if you make use of its benefits
20:03 pink_mist (sorry for bringing a totally unrelated topic in here)
20:05 Grinnz the old cgi way of thinking just isn't very applicable to a web application
20:12 disputin joined #mojo
20:12 disputin joined #mojo
20:19 sri mib_nwd2wv: 150% actually seems a little on the slow side, performance gain is often much more if you optimize, even 1000% wouldn't surprise me at all
20:20 pink_mist sri: don't worry, it wasn't 150%, it was 150x
20:21 sri oh, lol
20:50 c--_ joined #mojo
21:00 disputin joined #mojo
21:00 disputin joined #mojo
21:03 absolut_todd joined #mojo
21:12 disputin joined #mojo
21:33 hernan604 joined #mojo
21:38 Grinnz_ Mojo::Home++ # neat way to solve my problem of finding the home dir regardless of what script I started at, even scripts completely unrelated to mojo
21:40 genio hrm.  How have I never noticed that that existed?!
21:40 orev joined #mojo
21:45 Grinnz_ it's how "template" and "log" and other relative dirs work
22:00 punter joined #mojo
22:23 * sri wonders if anyone would use a squish filter for validation
22:27 disputin joined #mojo
22:29 sri hmm, there is one special case with validation filters we don't handle particularly elegant
22:29 bayashi joined #mojo
22:29 orev does a route group localize the availability of the flash?  I have a route that successfully flashes to a page, and another one outside of the group using the same code and the flash is not coming through
22:29 sri what if the filter leaves behind an empy string?
22:30 Grinnz_ orev: unlikely
22:30 sri with ->required('foo')->filter('trim') you might have "   " and it would pass the required check, but then become "" after the filter, which wouldn't pass ->required anymore
22:31 caeles joined #mojo
22:31 salparadise joined #mojo
22:32 sri if nobody has an idea for how to handle that, it might be worth considering the removal of validation filters again
22:32 sri i can see that become a security issue
22:34 ashimema joined #mojo
22:35 * sri pokes jberger, batman and lb
22:40 fkafka joined #mojo
22:42 fkafka Hey everyone, I'm setting some session params based on form post. Is there any way to force the param to always be an array ref? The param is set by a multiselect list, but if only one is selected then the session param is a scalar.
22:43 fkafka E.g., $c->session(foo => $c->every_param('bar')); If only one is selected in the multiselect, foo is scalar; if > 1, foo is array ref.
22:43 fkafka I basically want it to always be an array ref, even if there's only one element.
22:45 jberger sri: would you consider '   ' a valid required parameter?
22:45 sri jberger: it currently is
22:46 sri my first instinct was to make all whitespace parameters not valid... but that doesn't really solve the problem
22:46 sri you could make a filter to remove profanity
22:46 jberger it seems to me that if I tell it that it should be trimmed first and that results in an invalid parameter then that's what you want
22:46 sri and then end up with "" again
22:47 jberger also I don't see the security issue
22:47 sri i think it's very easy to overlook as an attack vector
22:47 jberger we can take that to the core channel if you want though
22:47 mspo null injection?
22:48 sri just being able to smuggle an empty string past a ->required check seems like a bad idea
22:49 jberger '' is a valid required?
22:49 sri no
22:50 batman joined #mojo
22:50 sri if it was we wouldn't have a problem
22:50 sri i don't mind discussing it here, since validation filters have not been released
22:51 sri so there is no existing attack vector
22:52 Phil21 do you currently allow a null string to pass ->required?
22:53 Phil21 oh, not released yet
22:53 sri define null string?
22:53 jberger ''
22:53 Phil21 to me, as a naive developer but someone with fairly extensive security "background" seeing stupid shit, I agree with your statement that it seems like a bad idea
22:54 Phil21 if I passed that through an input validate check for "is this a string" I'd not expect it able to be null, I guess is my high-level point
22:54 sri ->required('foo') right now checks for defined() and ne ''
22:54 Phil21 that sounds correct to me
22:54 jberger and so ->required('   ') is ok
22:54 Phil21 again, take with a huge grain of salt coming from me :)
22:54 sri the argument is the name of the filed, but yes
22:54 sri *field
22:55 jberger oh, yeah
22:55 jberger but you know what I mean
22:55 sri "    " is considered valid
22:55 sri now the problem with validation filters is that a ->filter('trim') can turn "    " into ""
22:55 jberger so as the developer, if I add a trim before that and they pass '   ' then I personally would want it to fail
22:55 Phil21 ah, that's a harder one. hrm.
22:56 jberger don't trim it if you want '    ' to be valid
22:56 jberger or as you say, implement a squish filter
22:56 sri special disclaimers for how to hold a security feature are a bad idea imo
22:57 jberger it doesn't cause a spurious pass though, so I don't see the security implication
22:57 jberger if it caused it to pass then I could see the probelm
22:57 sri it's an attack vector, maybe it's a password field or whatever, you make empty string special because it can't get past the validation checks...
22:58 jberger well, don't trim a password field is my first response ;-)
22:58 orev does expiring a session cause the flash to get lost?  if I disable $c->session( 'expires' => 1 );, then my flash message goes through.  this is a logout page and I'm trying to show a logout successful message
22:59 jberger orev: the flash is stored in the session
22:59 orev jberger: ok, that makes sense then! (doh)
22:59 jberger orev: yeah, that's a tough case
22:59 jberger I
22:59 jberger I've hit it too
23:00 orev jberger: any ideas on another way to handle it?
23:01 good_news_everyon joined #mojo
23:01 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://github.com/kraih/mojo/commit/b11650424f0044dc51425d213b67e13bd2a53b52
23:01 good_news_everyon mojo/master b116504 Sebastian Riedel: remove support for validation filters again
23:01 good_news_everyon left #mojo
23:01 orev maybe an encrypted get param
23:01 sri i think it's serious enough to reconsider filters
23:05 jberger sri: how do you replace the password parameter before you do the validation anyway?
23:05 sri what do you mean?
23:05 jberger "maybe it's a password field or whatever, you make empty string special because it can't get past the validation checks..."
23:06 sri you enter "something_you_know_gets_filtered_out"
23:06 jberger and then it fails validation
23:06 sri it passes ->required
23:07 jberger how?
23:07 sri because it's defined and not ""
23:07 sri filters happen when you call ->filter()
23:07 sri the required check happens when you call ->required()
23:08 jberger which in the case of '   ' has become '' and thus fails
23:08 sri fails what?
23:08 jberger fails required
23:08 sri no
23:08 jberger but it is ''
23:08 Phil21 that was my understanding too
23:08 sri it's not checked again after the filter
23:08 jberger I'm so confused
23:08 jberger oh really?
23:09 Phil21 why would filter eliminate -> required checks?
23:09 sri wow, so much confusion
23:09 Phil21 yup :)
23:09 jberger ok I gotcha
23:09 jberger can you call filter before required?
23:10 sri so, we have $validation->required('foo')->filter('trim');
23:10 sri and $validation->input({foo => "   "}) as our initial state
23:10 jberger yeah, I'm looking at https://github.com/kraih/mojo/commit/b11650424f0044dc51425d213b67e13bd2a53b52#diff-af7f52660125846348aa0b9dd5a72bf1L166
23:10 sri and $validation->output({})
23:10 genio it seems to me that filtering maybe should be a separate thing that happens before validation.  lumping them together seems to bring the confusion
23:11 Phil21 genio: yeah, that's how I thought it worked until just now
23:11 Phil21 hence my confusing
23:11 sri after ->required('foo') we have ->output({foo => "   "})
23:11 Phil21 confusion even
23:11 jberger the good news is that now we are all on the same page
23:11 sri and after ->filter('trim') we have ->output({foo => ""})
23:11 Phil21 alright, yeah that could be a security problem
23:11 sri and then $validation->is_valid would still be true
23:11 sri which is bad
23:12 sri yes, filtering before validation would work, but not look nearly as elegant
23:12 jberger could it be something like ->param('foo')->filter('trim')->required->is_valid
23:13 sri now you're redesigning the validation system
23:13 jberger or, could required take a filter as a second option
23:13 jberger ->required('foo', 'trim')
23:13 sri you have to work arguments for the filter into that
23:13 sri and multiple filters
23:14 jberger hmmm
23:14 sri like trim + profanity
23:14 Phil21 or just treat whitespace only as special ;)
23:15 Grinnz_ also, a filter could potentially make it fail other checks like ->in or ->like
23:15 jberger but those come later
23:15 jberger required comes first
23:15 Grinnz_ always?
23:15 jberger its what pulls the param out of the params
23:15 sri Phil21: doesn't work, profanity filter might result in "" too
23:15 jberger required/optional
23:16 Grinnz_ i see
23:16 Phil21 sri: yeah, was mostly being funny - Joel is next to me so I'm annoying him with dumb ideas
23:16 sri Phil21: haha
23:17 * jberger throws a coffee cup at Phil21
23:17 jberger a paper one, empty
23:17 Phil21 +6mo and that will be full of cement I'm sure
23:18 sri you can get quality throwing mugs from the mojolicious store! </sellout>
23:18 jberger sri: ahahhahahaha
23:19 Grinnz_ so in essence, the only way to do it right is to have the filter come first with whatever sets the topic (or set the topic itself)
23:19 jberger I still kinda like having the filter in the required/optional
23:19 jberger but we'd have to get the api right
23:20 Grinnz_ it's hard to think of how the API should be when i've never really used any validation framework lol
23:22 sri most validators don't actually have filters
23:22 sri at least those shipping with frameworks
23:25 jberger odd thought
23:26 jberger could you make is so that if required is called without a name it uses the topic
23:26 jberger ?
23:26 jberger ->optional('foo')->filter('trim')->required->is_valid
23:26 sri sure, but that's very unintuitive
23:28 jberger I think its ok IMO, as long as its documented as such
23:28 sri easier would be to tie a check to all filters that require something to remain or so
23:28 jberger that works too
23:29 genio all I can think of are cumbersome solutions.  Having a hidden filtered param for each param that validation acts on.  ->filter('foo')->trim()->...    ->param('foo') pulls unaltered, ->param_filtered('foo') gets your trimmed one.  ->validate works on filtered params if they exist?
23:29 sri just like ->check, every ->filter call already does nothing if the current topic is already invalid
23:29 sri so attaching a check is easy
23:31 sri call it a "filter" error or so
23:31 vicash hi. how do I get the unit tests to use a different config file such as myapp.test.conf instead of myapp.developer.conf ?
23:35 nicomen local $ENV{MOJO_MODE} = 'test'; my $t = Test::Mojo->new(), but I normally override a check in my MyApp.pm that sets $app->mode() based on $ENV{HARNESS_ACTIVE}
23:36 nicomen (actually I override a check in a custom config module that supports layering configs on top of eachother (default, some_mode, local)
23:37 sri oh wait, an attached check would make ->optional() awkward :S
23:37 vicash interesting !
23:37 sri ->optional('foo')->filter('trim')
23:38 sri or does it? do you expect an error or an ignored value for {foo => "   "}?
23:38 nicomen vicash: you can also just do:    $self->app->mode('test') if Module::Loaded::is_loaded('Test::Mojo');
23:40 vicash nicomen: thanks. all these options are good.
23:40 sri it gets even more awkward with {foo => ['bar', '   ']}
23:41 nicomen sri: is treating a filter the same as a check, except its return value is a a new validator object with its possibly changed value? add_filter( myFilter => ... ) would let you do ->myFilter->required->is_valid?
23:41 sri funny how something that seems so simple can turn into such a mess
23:41 nicomen (is it totally stupid?)
23:42 sri nicomen: where does the topic come from?
23:42 nicomen I thought the topic was part of the dispatched-on object
23:42 sri afraid your proposal makes no sense to me
23:43 nicomen ok
23:46 sri maybe we leave filters to third party plugins
23:47 sri sucks a little, since we are so close, but what can we do
23:51 sri i would open a github issue, but i'm too tired to explain all the problems again ;p
23:53 sri but feel free to post more proposals (preferably with patch)

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary