Security Advisories (2)
CVE-2024-58134 (2025-05-03)

Mojolicious versions from 0.999922 for Perl uses a hard coded string, or the application's class name, as a HMAC session secret by default. These predictable default secrets can be exploited to forge session cookies. An attacker who knows or guesses the secret could compute valid HMAC signatures for the session cookie, allowing them to tamper with or hijack another user's session.

CVE-2024-58135 (2025-05-03)

Mojolicious versions from 7.28 for Perl may generate weak HMAC session secrets. When creating a default app with the "mojo generate app" tool, a weak secret is written to the application's configuration file using the insecure rand() function, and used for authenticating and protecting the integrity of the application's sessions. This may allow an attacker to brute force the application's session keys.

NAME

Mojo::Content::MultiPart - HTTP multipart content

SYNOPSIS

use Mojo::Content::MultiPart;

my $multi = Mojo::Content::MultiPart->new;
$multi->parse('Content-Type: multipart/mixed; boundary=---foobar');
my $single = $multi->parts->[4];

DESCRIPTION

Mojo::Content::MultiPart is a container for HTTP multipart content, based on RFC 7230, RFC 7231 and RFC 2388.

EVENTS

Mojo::Content::MultiPart inherits all events from Mojo::Content and can emit the following new ones.

part

$multi->on(part => sub ($multi, $single) {...});

Emitted when a new Mojo::Content::Single part starts.

$multi->on(part => sub ($multi, $single) {
  return unless $single->headers->content_disposition =~ /name="([^"]+)"/;
  say "Field: $1";
});

ATTRIBUTES

Mojo::Content::MultiPart inherits all attributes from Mojo::Content and implements the following new ones.

parts

my $parts = $multi->parts;
$multi    = $multi->parts([Mojo::Content::Single->new]);

Content parts embedded in this multipart content, usually Mojo::Content::Single objects.

METHODS

Mojo::Content::MultiPart inherits all methods from Mojo::Content and implements the following new ones.

body_contains

my $bool = $multi->body_contains('foobarbaz');

Check if content parts contain a specific string.

body_size

my $size = $multi->body_size;

Content size in bytes.

build_boundary

my $boundary = $multi->build_boundary;

Generate a suitable boundary for content and add it to Content-Type header.

clone

my $clone = $multi->clone;

Return a new Mojo::Content::MultiPart object cloned from this content if possible, otherwise return undef.

get_body_chunk

my $bytes = $multi->get_body_chunk(0);

Get a chunk of content starting from a specific position. Note that it might not be possible to get the same chunk twice if content was generated dynamically.

is_multipart

my $bool = $multi->is_multipart;

True, this is a Mojo::Content::MultiPart object.

new

my $multi = Mojo::Content::MultiPart->new;
my $multi
  = Mojo::Content::MultiPart->new(parts => [Mojo::Content::Single->new]);
my $multi
  = Mojo::Content::MultiPart->new({parts => [Mojo::Content::Single->new]});

Construct a new Mojo::Content::MultiPart object and subscribe to event "read" in Mojo::Content with default content parser.

SEE ALSO

Mojolicious, Mojolicious::Guides, https://mojolicious.org.