mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +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',
|
||||
Rule::in($mediaTypes)
|
||||
],
|
||||
'*.url' => 'required|url|max:255',
|
||||
'*.url' => 'required|url',
|
||||
'*.mediaType' => [
|
||||
'required',
|
||||
'string',
|
||||
Rule::in($mimeTypes)
|
||||
],
|
||||
'*.name' => 'sometimes|nullable|string|max:255'
|
||||
'*.name' => 'sometimes|nullable|string'
|
||||
])->passes();
|
||||
|
||||
return $valid;
|
||||
|
@ -665,12 +665,13 @@ class Helpers {
|
|||
foreach($attachments as $media) {
|
||||
$type = $media['mediaType'];
|
||||
$url = $media['url'];
|
||||
$blurhash = isset($media['blurhash']) ? $media['blurhash'] : null;
|
||||
$license = isset($media['license']) ? License::nameToId($media['license']) : null;
|
||||
$valid = self::validateUrl($url);
|
||||
if(in_array($type, $allowed) == false || $valid == false) {
|
||||
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->blurhash = $blurhash;
|
||||
|
@ -680,6 +681,7 @@ class Helpers {
|
|||
$media->user_id = null;
|
||||
$media->media_path = $url;
|
||||
$media->remote_url = $url;
|
||||
$media->caption = $caption;
|
||||
if($license) {
|
||||
$media->license = $license;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue