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::DOM::HTML - HTML/XML engine

SYNOPSIS

use Mojo::DOM::HTML;

# Turn HTML into DOM tree
my $html = Mojo::DOM::HTML->new;
$html->parse('<div><p id="a">Test</p><p id="b">123</p></div>');
my $tree = $html->tree;

DESCRIPTION

Mojo::DOM::HTML is the HTML/XML engine used by Mojo::DOM, based on the HTML Living Standard and the Extensible Markup Language (XML) 1.0.

FUNCTIONS

Mojo::DOM::HTML implements the following functions, which can be imported individually.

tag_to_html

my $str = tag_to_html 'div', id => 'foo', 'safe content';

Generate HTML/XML tag and render it right away. This is a significantly faster alternative to "tag" for template systems that have to generate a lot of tags.

ATTRIBUTES

Mojo::DOM::HTML implements the following attributes.

tree

my $tree = $html->tree;
$html    = $html->tree(['root']);

Document Object Model. Note that this structure should only be used very carefully since it is very dynamic.

xml

my $bool = $html->xml;
$html    = $html->xml($bool);

Disable HTML semantics in parser and activate case-sensitivity, defaults to auto-detection based on XML declarations.

METHODS

Mojo::DOM::HTML inherits all methods from Mojo::Base and implements the following new ones.

parse

$html = $html->parse('<foo bar="baz">I ♥ Mojolicious!</foo>');

Parse HTML/XML fragment.

render

my $str = $html->render;

Render DOM to HTML/XML.

tag

$html = $html->tag('div', id => 'foo', 'safe content');

Generate HTML/XML tag.

SEE ALSO

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