Skip to content

Commit

Permalink
Connector import : restrict media names to up to 95 characters. (#2872)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMis authored Jan 23, 2025
1 parent d59e265 commit 1e89229
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Controller/Library.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2024 Xibo Signage Ltd
* Copyright (C) 2025 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -2818,9 +2818,14 @@ public function connectorImport(Request $request, Response $response)

// Queue this for upload.
// Use a module to make sure our type, etc is supported.
// make sure the name is not longer than 100 characters.
$name = $import->searchResult->title;
if (strlen($name) >= 100) {
$name = trim(preg_replace('/\s+?(\S+)?$/', '', substr($name, 0, 95)), ', ');
}
$module = $this->getModuleFactory()->getByType($import->searchResult->type);
$import->media = $this->mediaFactory->queueDownload(
$import->searchResult->title,
$name,
str_replace(' ', '%20', htmlspecialchars_decode($import->url)),
0,
[
Expand Down

0 comments on commit 1e89229

Please sign in to comment.