mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update AP Helpers, fix media validation bug that would reject media with alttext/name longer than 255 chars and store remote alt text if set
This commit is contained in:
parent
016c6e4144
commit
a7f583497c
1 changed files with 6 additions and 4 deletions
|
@ -101,13 +101,13 @@ class Helpers {
|
||||||
'string',
|
'string',
|
||||||
Rule::in($mediaTypes)
|
Rule::in($mediaTypes)
|
||||||
],
|
],
|
||||||
'*.url' => 'required|url|max:255',
|
'*.url' => 'required|url',
|
||||||
'*.mediaType' => [
|
'*.mediaType' => [
|
||||||
'required',
|
'required',
|
||||||
'string',
|
'string',
|
||||||
Rule::in($mimeTypes)
|
Rule::in($mimeTypes)
|
||||||
],
|
],
|
||||||
'*.name' => 'sometimes|nullable|string|max:255'
|
'*.name' => 'sometimes|nullable|string'
|
||||||
])->passes();
|
])->passes();
|
||||||
|
|
||||||
return $valid;
|
return $valid;
|
||||||
|
@ -665,12 +665,13 @@ class Helpers {
|
||||||
foreach($attachments as $media) {
|
foreach($attachments as $media) {
|
||||||
$type = $media['mediaType'];
|
$type = $media['mediaType'];
|
||||||
$url = $media['url'];
|
$url = $media['url'];
|
||||||
$blurhash = isset($media['blurhash']) ? $media['blurhash'] : null;
|
|
||||||
$license = isset($media['license']) ? License::nameToId($media['license']) : null;
|
|
||||||
$valid = self::validateUrl($url);
|
$valid = self::validateUrl($url);
|
||||||
if(in_array($type, $allowed) == false || $valid == false) {
|
if(in_array($type, $allowed) == false || $valid == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$blurhash = isset($media['blurhash']) ? $media['blurhash'] : null;
|
||||||
|
$license = isset($media['license']) ? License::nameToId($media['license']) : null;
|
||||||
|
$caption = $media['name'] ? Purify::clean($media['name']) : null;
|
||||||
|
|
||||||
$media = new Media();
|
$media = new Media();
|
||||||
$media->blurhash = $blurhash;
|
$media->blurhash = $blurhash;
|
||||||
|
@ -680,6 +681,7 @@ class Helpers {
|
||||||
$media->user_id = null;
|
$media->user_id = null;
|
||||||
$media->media_path = $url;
|
$media->media_path = $url;
|
||||||
$media->remote_url = $url;
|
$media->remote_url = $url;
|
||||||
|
$media->caption = $caption;
|
||||||
if($license) {
|
if($license) {
|
||||||
$media->license = $license;
|
$media->license = $license;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue