Screenshots/Crop

* fixed coordinate filter broken after a8edf6c912
This commit is contained in:
Sarjuuk
2022-03-28 00:58:43 +02:00
parent b3e8f5e50f
commit b08d30d043
2 changed files with 11 additions and 3 deletions

View File

@@ -103,7 +103,7 @@ trait TrRequestData
private static function checkIdListUnsigned(string $val) : array
{
if (preg_match('/\d+(,\d+)*/', $val))
if (preg_match('/^\d+(,\d+)*$/', $val))
return array_map('intVal', explode(',', $val));
return [];

View File

@@ -28,7 +28,7 @@ class ScreenshotPage extends GenericPage
protected $imgHash = '';
protected $_post = array(
'coords' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkIdListUnsigned'],
'coords' => ['filter' => FILTER_CALLBACK, 'options' => 'ScreenshotPage::checkCoords'],
'screenshotalt' => ['filter' => FILTER_UNSAFE_RAW, 'flags' => FILTER_FLAG_STRIP_AOWOW]
);
@@ -196,7 +196,7 @@ class ScreenshotPage extends GenericPage
if (count($dims) != 4)
return 3;
Util::checkNumeric($dims, NUM_REQ_INT);
Util::checkNumeric($dims, NUM_CAST_FLOAT);
// actually crop the image
$srcImg = imagecreatefromjpeg($fullPath);
@@ -333,6 +333,14 @@ class ScreenshotPage extends GenericPage
return $this->imgHash ? User::$displayName.'-'.$this->destType.'-'.$this->destTypeId.'-'.$this->imgHash : '';
}
protected static function checkCoords(string $val) : array
{
if (preg_match('/^[01]\.[0-9]{3}(,[01]\.[0-9]{3}){3}$/', $val))
return explode(',', $val);
return [];
}
protected function generatePath() : void { }
protected function generateTitle() : void
{