Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vtigercrm
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Welcome to Vtiger Community. To gain access for account, please contact [ community @ vtiger.com ]
Show more breadcrumbs
Code80
vtigercrm
Commits
9569b09e
Commit
9569b09e
authored
4 years ago
by
Uma
Browse files
Options
Downloads
Patches
Plain Diff
File threat for xss attack on end point addressed
parent
b8bb34cf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/Vtiger/helpers/ShowFile.php
+9
-5
9 additions, 5 deletions
modules/Vtiger/helpers/ShowFile.php
vtlib/Vtiger/Functions.php
+1
-1
1 addition, 1 deletion
vtlib/Vtiger/Functions.php
with
10 additions
and
6 deletions
modules/Vtiger/helpers/ShowFile.php
+
9
−
5
View file @
9569b09e
...
...
@@ -21,8 +21,8 @@ class Vtiger_ShowFile_Helper {
$query
=
"SELECT vtiger_attachments.* FROM vtiger_attachments
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_attachments.attachmentsid
WHERE vtiger_attachments.attachmentsid=?
AND vtiger_attachments.name=?
LIMIT 1"
;
$result
=
$db
->
pquery
(
$query
,
array
(
$fid
,
$encFileName
));
WHERE vtiger_attachments.attachmentsid=? LIMIT 1"
;
$result
=
$db
->
pquery
(
$query
,
array
(
$fid
));
if
(
$result
&&
$db
->
num_rows
(
$result
))
{
$resultData
=
$db
->
fetch_array
(
$result
);
$fileId
=
$resultData
[
'attachmentsid'
];
...
...
@@ -30,7 +30,7 @@ class Vtiger_ShowFile_Helper {
$fileName
=
$resultData
[
'name'
];
$storedFileName
=
$resultData
[
'storedname'
];
$fileType
=
$resultData
[
'type'
];
$sanitizedFileName
=
sanitizeUploadFileName
(
$fileName
,
$upload_badext
);
$sanitizedFileName
=
decode_html
(
sanitizeUploadFileName
(
$fileName
,
$upload_badext
)
)
;
/**
* While saving the document applying decode_html to save in DB, but this is not happening for the images
...
...
@@ -52,7 +52,7 @@ class Vtiger_ShowFile_Helper {
}
}
if
(
$isFileExist
)
{
Vtiger_ShowFile_Helper
::
show
(
$finalFilePath
,
$fileType
);
Vtiger_ShowFile_Helper
::
show
(
$finalFilePath
,
$fileType
,
$sanitizedFileName
);
}
}
}
...
...
@@ -63,11 +63,15 @@ class Vtiger_ShowFile_Helper {
* @param type $finalFilePath - the proper image folder path
* @param type $fileType - image file type
*/
static
function
show
(
$finalFilePath
,
$fileType
)
{
static
function
show
(
$finalFilePath
,
$fileType
,
$sanitizedFileName
=
false
)
{
$handle
=
fopen
(
$finalFilePath
,
"rb"
);
$contents
=
fread
(
$handle
,
filesize
(
$finalFilePath
));
fclose
(
$handle
);
//added since other than image files we need file names, other wise it downloads with public.php extension which is treated as dangerous
if
(
$sanitizedFileName
)
{
header
(
"Content-Disposition: attachment; filename=
\"
$sanitizedFileName
\"
"
);
}
header
(
"Content-Type:
$fileType
;charset=UTF-8"
);
echo
$contents
;
}
...
...
This diff is collapsed.
Click to expand it.
vtlib/Vtiger/Functions.php
+
1
−
1
View file @
9569b09e
...
...
@@ -1553,7 +1553,7 @@ class Vtiger_Functions {
$fileId
=
$imageId
;
$fileName
=
$imageName
;
if
(
$fileId
)
{
$publicUrl
=
"public.php?fid=
$fileId
&key="
.
$fileName
;
$publicUrl
=
"public.php?fid=
$fileId
&key="
.
md5
(
$fileName
)
;
}
return
$publicUrl
;
}
...
...
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