Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
b5392c29
Commit
b5392c29
authored
3 years ago
by
Quentin Ribac
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/external/alfresco/controllers/AlfrescoController.php
+10
-1
10 additions, 1 deletion
src/app/external/alfresco/controllers/AlfrescoController.php
with
10 additions
and
1 deletion
src/app/external/alfresco/controllers/AlfrescoController.php
+
10
−
1
View file @
b5392c29
...
@@ -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'
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment