Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/BBCode/Attach.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public function validate(BBCodeInterface &$bbc, array|string &$data, array $disa
}
}

foreach (['alt', 'width', 'height'] as $k) {
$params[$k] = Utils::htmlspecialchars($params[$k], ENT_QUOTES);
}

// Embedded file.
if ($params['{display}'] == 'embed') {
$alt = ' alt="' . (!empty($params['{alt}']) ? $params['{alt}'] : $current_attachment['name']) . '"';
Expand Down
3 changes: 2 additions & 1 deletion Sources/BBCode/Img.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace SMF\BBCode;

use SMF\Url;
use SMF\Utils;

/**
* Represents the img BBCode.
Expand Down Expand Up @@ -74,7 +75,7 @@ public function validate(BBCodeInterface &$bbc, array|string &$data, array $disa
$url = $url->proxied();
}

$alt = !empty($params['{alt}']) ? ' alt="' . $params['{alt}'] . '"' : ' alt=""';
$alt = !empty($params['{alt}']) ? ' alt="' . Utils::htmlspecialchars($params['{alt}'], ENT_QUOTES) . '"' : ' alt=""';
$title = !empty($params['{title}']) ? ' title="' . $params['{title}'] . '"' : '';

$data = isset($disabled[$bbc->tag]) ? $url : '<img src="' . $url . '"' . $alt . $title . $params['{width}'] . $params['{height}'] . ' class="bbc_img' . (!empty($params['{width}']) || !empty($params['{height}']) ? ' resized' : '') . '" loading="lazy">';
Expand Down
2 changes: 1 addition & 1 deletion Sources/Parsers/BBCodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ protected function detectBBCode(string $tag_character): array
}

// Just to make sure: replace any $ or { so they can't interpolate wrongly.
$params['{' . $key . '}'] = Utils::htmlspecialchars(strtr($params['{' . $key . '}'], ['$' => '&#036;', '{' => '&#123;']), ENT_QUOTES);
$params['{' . $key . '}'] = strtr($params['{' . $key . '}'], ['$' => '&#036;', '{' => '&#123;']);
}

foreach ($possible->parameters as $p => $info) {
Expand Down
Loading