diff -Nru libmojolicious-perl-8.10+dfsg/Changes libmojolicious-perl-8.11+dfsg/Changes --- libmojolicious-perl-8.10+dfsg/Changes 2018-12-17 23:13:03.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/Changes 2019-01-02 13:50:33.000000000 +0000 @@ -1,4 +1,14 @@ +8.11 2019-01-01 + - Added EXPERIMENTAL support for SameSite cookies to better protect + Mojolicious applications from CSRF attacks. (dylanwh, sri) + - Added EXPERIMENTAL samesite attributes to Mojo::Cookie::Response and + Mojolicious::Cookies. (dylanwh, sri) + - Added lstat method to Mojo::File. (Grinnz) + - Added remove method to Mojo::File. + - Improved eval command with support for promises. (jberger) + - Improved Mojo::JSON::Pointer to ignore many invalid JSON Pointers. + 8.10 2018-12-18 - Added reset event to Mojo::IOLoop. - Added limit argument to split method in Mojo::ByteStream. (s1037989) diff -Nru libmojolicious-perl-8.10+dfsg/debian/changelog libmojolicious-perl-8.11+dfsg/debian/changelog --- libmojolicious-perl-8.10+dfsg/debian/changelog 2018-12-26 16:51:23.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/debian/changelog 2019-01-03 22:47:31.000000000 +0000 @@ -1,3 +1,10 @@ +libmojolicious-perl (8.11+dfsg-1) unstable; urgency=medium + + * Import upstream version 8.11+dfsg. + * Update years of upstream and packaging copyright. + + -- gregor herrmann Thu, 03 Jan 2019 23:47:31 +0100 + libmojolicious-perl (8.10+dfsg-1) unstable; urgency=medium * Import upstream version 8.10+dfsg. diff -Nru libmojolicious-perl-8.10+dfsg/debian/copyright libmojolicious-perl-8.11+dfsg/debian/copyright --- libmojolicious-perl-8.10+dfsg/debian/copyright 2018-12-26 16:51:23.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/debian/copyright 2019-01-03 22:47:31.000000000 +0000 @@ -9,16 +9,16 @@ lib/Mojolicious/resources/public/mojo/prettify/run_prettify.js Files: * -Copyright: 2008-2018, Sebastian Riedel +Copyright: 2008-2019, Sebastian Riedel License: Artistic-2.0 Files: lib/Mojolicious/resources/public/mojo/* -Copyright: 2010-2018, Sebastian Riedel +Copyright: 2010-2019, Sebastian Riedel License: CC-BY-SA-4.0 Files: debian/* Copyright: 2010-2011, Jonathan Yu - 2010-2018, gregor herrmann + 2010-2019, gregor herrmann 2011, Angel Abad 2011, Fabrizio Regalli 2011-2012, Krzysztof Krzyżaniak (eloy) diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojo/Asset/File.pm libmojolicious-perl-8.11+dfsg/lib/Mojo/Asset/File.pm --- libmojolicious-perl-8.10+dfsg/lib/Mojo/Asset/File.pm 2018-11-22 20:21:44.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojo/Asset/File.pm 2019-01-02 14:14:21.000000000 +0000 @@ -34,7 +34,7 @@ if (my $handle = $self->handle) { close $handle } # Only the process that created the file is allowed to remove it - unlink $path if -w $path && ($self->{pid} // $$) == $$; + Mojo::File->new($path)->remove if -w $path && ($self->{pid} // $$) == $$; } sub add_chunk { diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojo/Cookie/Response.pm libmojolicious-perl-8.11+dfsg/lib/Mojo/Cookie/Response.pm --- libmojolicious-perl-8.10+dfsg/lib/Mojo/Cookie/Response.pm 2018-11-22 20:21:53.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojo/Cookie/Response.pm 2018-12-30 15:08:25.000000000 +0000 @@ -4,9 +4,10 @@ use Mojo::Date; use Mojo::Util qw(quote split_cookie_header); -has [qw(domain expires host_only httponly max_age path secure)]; +has [qw(domain expires host_only httponly max_age path samesite secure)]; -my %ATTRS = map { $_ => 1 } qw(domain expires httponly max-age path secure); +my %ATTRS + = map { $_ => 1 } qw(domain expires httponly max-age path samesite secure); sub parse { my ($self, $str) = @_; @@ -53,6 +54,9 @@ # "HttpOnly" $cookie .= "; HttpOnly" if $self->httponly; + # "Same-Site" + if (my $samesite = $self->samesite) { $cookie .= "; SameSite=$samesite" } + # "Max-Age" if (defined(my $max = $self->max_age)) { $cookie .= "; Max-Age=$max" } @@ -130,6 +134,16 @@ Cookie path. +=head2 samesite + + my $samesite = $cookie->samesite; + $cookie = $cookie->samesite('Lax'); + +SameSite value. Note that this attribute is EXPERIMENTAL because even though +most commonly used browsers support the feature, there is no specification yet +besides +L. + =head2 secure my $bool = $cookie->secure; diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojo/File.pm libmojolicious-perl-8.11+dfsg/lib/Mojo/File.pm --- libmojolicious-perl-8.10+dfsg/lib/Mojo/File.pm 2018-12-12 00:44:43.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojo/File.pm 2019-01-02 13:49:30.000000000 +0000 @@ -78,6 +78,8 @@ return Mojo::Collection->new(map { $self->new(canonpath $_) } sort keys %all); } +sub lstat { File::stat::lstat(${shift()}) } + sub make_path { my $self = shift; File::Path::make_path $$self, @_; @@ -107,6 +109,12 @@ sub realpath { $_[0]->new(Cwd::realpath ${$_[0]}) } +sub remove { + my ($self, $mode) = @_; + unlink $$self or croak qq{Can't remove file "$$self": $!} if -e $$self; + return $self; +} + sub remove_tree { my $self = shift; File::Path::remove_tree $$self, @_; @@ -369,6 +377,18 @@ =back +=head2 lstat + + my $stat = $path->lstat; + +Return a L object for the symlink. + + # Get symlink size + say path('/usr/sbin/sendmail')->lstat->size; + + # Get symlink modification time + say path('/usr/sbin/sendmail')->lstat->mtime; + =head2 make_path $path = $path->make_path; @@ -418,6 +438,12 @@ Resolve the path with L and return the result as a L object. +=head2 remove + + $path = $path->remove; + +Delete file. + =head2 remove_tree $path = $path->remove_tree; diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojo/IOLoop/Server.pm libmojolicious-perl-8.11+dfsg/lib/Mojo/IOLoop/Server.pm --- libmojolicious-perl-8.10+dfsg/lib/Mojo/IOLoop/Server.pm 2018-11-22 20:21:54.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojo/IOLoop/Server.pm 2019-01-02 13:56:13.000000000 +0000 @@ -4,6 +4,7 @@ use Carp 'croak'; use IO::Socket::IP; use IO::Socket::UNIX; +use Mojo::File 'path'; use Mojo::IOLoop; use Mojo::IOLoop::TLS; use Scalar::Util 'weaken'; @@ -57,7 +58,7 @@ # UNIX domain socket my $reuse; if ($path) { - unlink $path if -S $path; + path($path)->remove if -S $path; $options{Local} = $path; $handle = $class->new(%options) or croak "Can't create listen socket: $!"; $reuse = $self->{reuse} = join ':', 'unix', $path, fileno $handle; diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojo/JSON/Pointer.pm libmojolicious-perl-8.11+dfsg/lib/Mojo/JSON/Pointer.pm --- libmojolicious-perl-8.10+dfsg/lib/Mojo/JSON/Pointer.pm 2018-12-16 16:59:09.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojo/JSON/Pointer.pm 2018-12-30 15:39:40.000000000 +0000 @@ -3,16 +3,16 @@ has 'data'; -sub contains { shift->_pointer(1, @_) } -sub get { shift->_pointer(0, @_) } +sub contains { shift->_pointer(0, @_) } +sub get { shift->_pointer(1, @_) } sub new { @_ > 1 ? shift->SUPER::new(data => shift) : shift->SUPER::new } sub _pointer { - my ($self, $contains, $pointer) = @_; + my ($self, $get, $pointer) = @_; my $data = $self->data; - return $contains ? 1 : $data unless $pointer =~ s!^/!!; + return length $pointer ? undef : $get ? $data : 1 unless $pointer =~ s!^/!!; for my $p (length $pointer ? (split '/', $pointer, -1) : ($pointer)) { $p =~ s!~1!/!g; $p =~ s/~0/~/g; @@ -29,7 +29,7 @@ else { return undef } } - return $contains ? 1 : $data; + return $get ? $data : 1; } 1; diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojo/Server/Hypnotoad.pm libmojolicious-perl-8.11+dfsg/lib/Mojo/Server/Hypnotoad.pm --- libmojolicious-perl-8.10+dfsg/lib/Mojo/Server/Hypnotoad.pm 2018-11-22 20:21:47.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojo/Server/Hypnotoad.pm 2019-01-02 14:13:39.000000000 +0000 @@ -92,7 +92,7 @@ return unless my $new = $self->{new}; my $prefork = $self->prefork->cleanup(0); - unlink $prefork->pid_file; + path($prefork->pid_file)->remove; $prefork->ensure_pid_file($new); } diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojo/Server/Prefork.pm libmojolicious-perl-8.11+dfsg/lib/Mojo/Server/Prefork.pm --- libmojolicious-perl-8.10+dfsg/lib/Mojo/Server/Prefork.pm 2018-11-22 20:21:48.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojo/Server/Prefork.pm 2019-01-02 14:12:35.000000000 +0000 @@ -17,19 +17,18 @@ has spare => 2; has workers => 4; -sub DESTROY { unlink $_[0]->pid_file if $_[0]->cleanup } +sub DESTROY { path($_[0]->pid_file)->remove if $_[0]->cleanup } sub check_pid { - my $file = shift->pid_file; - return undef unless open my $handle, '<', $file; - my $pid = <$handle>; + return undef unless -r (my $file = path(shift->pid_file)); + my $pid = $file->slurp; chomp $pid; # Running return $pid if $pid && kill 0, $pid; # Not running - unlink $file; + $file->remove; return undef; } @@ -37,15 +36,14 @@ my ($self, $pid) = @_; # Check if PID file already exists - return if -e (my $file = $self->pid_file); + return if -e (my $file = path($self->pid_file)); # Create PID file - $self->app->log->error(qq{Can't create process id file "$file": $!}) - and die qq{Can't create process id file "$file": $!} - unless open my $handle, '>', $file; + if (my $err = eval { $file->spurt("$pid\n")->chmod(0644) } ? undef : $@) { + $self->app->log->error(qq{Can't create process id file "$file": $err}) + and die qq{Can't create process id file "$file": $err}; + } $self->app->log->info(qq{Creating process id file "$file"}); - chmod 0644, $handle; - print $handle "$pid\n"; } sub healthy { diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojolicious/Command/eval.pm libmojolicious-perl-8.11+dfsg/lib/Mojolicious/Command/eval.pm --- libmojolicious-perl-8.10+dfsg/lib/Mojolicious/Command/eval.pm 2018-11-22 20:22:05.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojolicious/Command/eval.pm 2018-12-31 13:59:25.000000000 +0000 @@ -1,6 +1,7 @@ package Mojolicious::Command::eval; use Mojo::Base 'Mojolicious::Command'; +use Mojo::Promise; use Mojo::Util 'getopt'; has description => 'Run code against application'; @@ -13,10 +14,17 @@ my $code = shift @args || ''; # Run code against application - my $app = $self->app; - no warnings; + my $app = $self->app; my $result = eval "package main; sub app; local *app = sub { \$app }; $code"; - return $@ ? die $@ : $result unless defined $result && ($v1 || $v2); + die $@ if $@; + + # Handle promises + my $err; + Mojo::Promise->resolve($result) + ->then(sub { $result = shift }, sub { $err = shift })->wait; + die $err if $err; + + return $result unless defined $result && ($v1 || $v2); $v2 ? print($app->dumper($result)) : say $result; } @@ -48,7 +56,9 @@ =head1 DESCRIPTION -L runs code against applications. +L runs code against applications. If the result is a +promise (then-able), it will wait until the promise is fulfilled or rejected and +the result is returned. This is a core command, that means it is always enabled and its code a good example for learning to build new commands, you're welcome to fork it. diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojolicious/Guides/Contributing.pod libmojolicious-perl-8.11+dfsg/lib/Mojolicious/Guides/Contributing.pod --- libmojolicious-perl-8.10+dfsg/lib/Mojolicious/Guides/Contributing.pod 2018-12-16 22:14:22.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojolicious/Guides/Contributing.pod 2018-12-31 12:37:21.000000000 +0000 @@ -88,12 +88,10 @@ now!|https://kiwiirc.com/nextclient/#irc://irc.freenode.net/mojo?nick=guest-?>), to avoid unnecessary work and to increase its chances of getting accepted. -To get early feedback and reviews for your code changes you can also open a -B pull request. But you will have to declare a deadline after -which the pull request should be considered finished or failed in the -description. Otherwise all pull requests are considered finished and ready for -voting. If changes have been requested for your pull request, you have 24 hours -to address these requests, or you can try again with a new pull request later. +Any member of the core team can call for a vote with a GitHub comment mentioning +the team C<@mojolicious/core>. Then there will be a review period of 14 days (or +less if enough votes have been cast), after which all votes are counted and the +pull request will be accepted or rejected. The following mission statement and rules are the foundation of all L and L development. Please make sure that your contribution aligns well diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojolicious/resources/templates/mojo/debug.html.ep libmojolicious-perl-8.11+dfsg/lib/Mojolicious/resources/templates/mojo/debug.html.ep --- libmojolicious-perl-8.10+dfsg/lib/Mojolicious/resources/templates/mojo/debug.html.ep 2018-07-23 14:04:22.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojolicious/resources/templates/mojo/debug.html.ep 2019-01-01 18:21:42.000000000 +0000 @@ -10,7 +10,9 @@ %= javascript '/mojo/prettify/run_prettify.js' %= stylesheet '/mojo/prettify/prettify-mojo-dark.css' - %= include 'mojo/menubar' +
+ %= link_to 'https://mojolicious.org' => (id => 'mojobar-brand') => begin + + + + % end + +
diff -Nru libmojolicious-perl-8.10+dfsg/lib/Mojolicious/resources/templates/mojo/not_found.html.ep libmojolicious-perl-8.11+dfsg/lib/Mojolicious/resources/templates/mojo/not_found.html.ep --- libmojolicious-perl-8.10+dfsg/lib/Mojolicious/resources/templates/mojo/not_found.html.ep 2018-05-21 21:40:33.000000000 +0000 +++ libmojolicious-perl-8.11+dfsg/lib/Mojolicious/resources/templates/mojo/not_found.html.ep 2019-01-01 18:11:24.000000000 +0000 @@ -4,8 +4,12 @@ Page not found - %= include 'mojo/menubar'