mirror of
https://github.com/matrix-construct/construct
synced 2024-09-25 09:58:54 +02:00
modules/media/thumbnail: Use clamp for query param bounds.
This commit is contained in:
parent
1a756f637f
commit
f201215fdb
1 changed files with 10 additions and 11 deletions
|
@ -182,23 +182,22 @@ get__thumbnail_local(client &client,
|
|||
request.query.get("method", "scale"_sv)
|
||||
};
|
||||
|
||||
std::pair<size_t, size_t> dimension
|
||||
const size_t _dimension[]
|
||||
{
|
||||
request.query.get<size_t>("width", 0),
|
||||
request.query.get<size_t>("height", 0)
|
||||
request.query.get<size_t>("height", 0),
|
||||
};
|
||||
|
||||
if(dimension.first)
|
||||
const pair<size_t> dimension
|
||||
{
|
||||
dimension.first = std::max(dimension.first, size_t(width_min));
|
||||
dimension.first = std::min(dimension.first, size_t(width_max));
|
||||
}
|
||||
_dimension[0]?
|
||||
std::clamp(_dimension[0], size_t(width_min), size_t(width_max)):
|
||||
_dimension[0],
|
||||
|
||||
if(dimension.second)
|
||||
{
|
||||
dimension.second = std::max(dimension.second, size_t(height_min));
|
||||
dimension.second = std::min(dimension.second, size_t(height_max));
|
||||
}
|
||||
_dimension[1]?
|
||||
std::clamp(_dimension[1], size_t(height_min), size_t(height_max)):
|
||||
_dimension[1]
|
||||
};
|
||||
|
||||
static const m::event::fetch::opts fopts
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue