Skip to content
Snippets Groups Projects
Commit b5392c29 authored by Quentin Ribac's avatar Quentin Ribac
Browse files

FIX #17560 TIME 0:45 Alfresco: sanitize document subject and attachment title

parent 0209cf53
No related branches found
No related tags found
No related merge requests found
...@@ -611,7 +611,13 @@ class AlfrescoController ...@@ -611,7 +611,13 @@ class AlfrescoController
} }
$resourceFolderId = $curlResponse['response']['entry']['id']; $resourceFolderId = $curlResponse['response']['entry']['id'];
$document['subject'] = str_replace([':', '*', '\'', '"', '>', '<'], ' ', $document['subject']); // regex matching INVALID folder or document name, used in Alfresco:
// (.*[\"\*\\\>\<\?\/\:\|]+.*)|(.*[\.]?.*[\.]+$)|(.*[ ]+$)
$alfrescoCharRefused = str_split('"*\\><?/:|');
$alfrescoCharToTrim = '. ';
$document['subject'] = str_replace($alfrescoCharRefused, ' ', $document['subject']); // replace refused characters with a blank space
$document['subject'] = preg_replace('/\s+/u', ' ', $document['subject']); // squeeze spaces including unicode ones
$document['subject'] = trim($document['subject'], $alfrescoCharToTrim); // trim beginning and end
$multipartBody = [ $multipartBody = [
'filedata' => ['isFile' => true, 'filename' => $document['subject'], 'content' => $fileContent], 'filedata' => ['isFile' => true, 'filename' => $document['subject'], 'content' => $fileContent],
]; ];
...@@ -735,6 +741,9 @@ class AlfrescoController ...@@ -735,6 +741,9 @@ class AlfrescoController
$firstAttachment = true; $firstAttachment = true;
$attachmentsTitlesSent = []; $attachmentsTitlesSent = [];
foreach ($attachments as $attachment) { foreach ($attachments as $attachment) {
$attachment['title'] = str_replace($alfrescoCharRefused, ' ', $attachment['title']);
$attachment['title'] = preg_replace('/\s+/u', ' ', $attachment['title']);
$attachment['title'] = trim($attachment['title'], $alfrescoCharToTrim);
$adrInfo = [ $adrInfo = [
'docserver_id' => $attachment['docserver_id'], 'docserver_id' => $attachment['docserver_id'],
'path' => $attachment['path'], 'path' => $attachment['path'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment