/usr/share/perl5/Mojo/Cookie.pm is in libmojolicious-perl 2.23-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | package Mojo::Cookie;
use Mojo::Base -base;
use overload
'bool' => sub {1},
'""' => sub { shift->to_string },
fallback => 1;
use Carp 'croak';
use Mojo::Util 'unquote';
has [qw/name path value version/];
my $COOKIE_SEPARATOR_RE = qr/^\s*\,\s*/;
my $NAME_RE = qr/
^\s*
(?<name>[^\=\;\,]+) # Relaxed Netscape token, allowing whitespace
\s*
\=? # '=' (optional)
\s*
/x;
my $SEPARATOR_RE = qr/^\s*\;\s*/;
my $VALUE_RE = qr/
^
(?<value>
"(?:\\\\|\\"|[^"])+" # Quoted
|
[^\;\,]+ # Unquoted
)
\s*
/x;
# "My Homer is not a communist.
# He may be a liar, a pig, an idiot, a communist,
# but he is not a porn star."
sub to_string { croak 'Method "to_string" not implemented by subclass' }
sub _tokenize {
my ($self, $string) = @_;
# Nibbling parser
my (@tree, @token);
while ($string) {
# Name
if ($string =~ s/$NAME_RE//) {
my $name = $+{name};
# "expires" is a special case, thank you Netscape...
$string =~ s/^([^\;\,]+\,?[^\;\,]+)/"$1"/ if $name =~ /^expires$/i;
# Value
my $value;
$value = unquote $+{value} if $string =~ s/$VALUE_RE//;
# Token
push @token, [$name, $value];
# Separator
$string =~ s/$SEPARATOR_RE//;
if ($string =~ s/$COOKIE_SEPARATOR_RE//) {
push @tree, [@token];
@token = ();
}
}
# Bad format
else {last}
}
# No separator
push @tree, [@token] if @token;
return @tree;
}
1;
__END__
=head1 NAME
Mojo::Cookie - HTTP 1.1 cookie base class
=head1 SYNOPSIS
use Mojo::Base 'Mojo::Cookie';
=head1 DESCRIPTION
L<Mojo::Cookie> is an abstract base class for HTTP 1.1 cookies.
=head1 ATTRIBUTES
L<Mojo::Cookie> implements the following attributes.
=head2 C<name>
my $name = $cookie->name;
$cookie = $cookie->name('foo');
Cookie name.
=head2 C<path>
my $path = $cookie->path;
$cookie = $cookie->path('/test');
Cookie path.
=head2 C<value>
my $value = $cookie->value;
$cookie = $cookie->value('/test');
Cookie value.
=head2 C<version>
my $version = $cookie->version;
$cookie = $cookie->version(1);
Cookie version.
=head1 METHODS
L<Mojo::Cookie> inherits all methods from L<Mojo::Base> and implements the
following new ones.
=head2 C<to_string>
my $string = $cookie->to_string;
Render cookie.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
=cut
|