[Dancer-users] A new dancer plugin.

David Precious davidp at preshweb.co.uk
Sun May 13 20:02:21 CEST 2012


On Sun, 13 May 2012 19:34:28 +0200 (CEST)
igor.bujna at post.cz wrote:

> Hi,
> looks good, but I think you have little bug in this lines in subs
> _set_hsts_header:
> 
> sub _set_hsts_header {
>     my $settings    = plugin_setting;
>     my $hsts_age    = $settings->{hsts_age} // 31536000;
>     my $subdomains  = $settings->{hsts_include_subdomains} // 0;
> 
> Should be place this '||' than '//'
> 
>     my $hsts_age    = $settings->{hsts_age} || 31536000;
>     my $subdomains  = $settings->{hsts_include_subdomains} || 0;

the // instead of || tests for definedness rather than truth.

Your version means that, if you set hsts_age to 0 in the config, the
default of a year would be used instead - that's quite probably not
desirable.

I believe defined-or was introduced in 5.10, though, and the plugin
doesn't include 'use 5.010' or similar, so I imagine there will be
failures on < 5.8 perls.


-- 
David Precious ("bigpresh") <davidp at preshweb.co.uk>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github


More information about the Dancer-users mailing list