Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
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
Show more breadcrumbs
drupal.org
feeds
Commits
94aae911
Commit
94aae911
authored
14 years ago
by
Alex Barth
Browse files
Options
Downloads
Patches
Plain Diff
Fix file extension validation.
parent
7b9ed6b8
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
plugins/FeedsFileFetcher.inc
+11
-5
11 additions, 5 deletions
plugins/FeedsFileFetcher.inc
with
11 additions
and
5 deletions
plugins/FeedsFileFetcher.inc
+
11
−
5
View file @
94aae911
...
...
@@ -90,9 +90,8 @@ class FeedsFileFetcher extends FeedsFetcher {
// If there is a file uploaded, save it, otherwise validate input on
// file.
if
(
$file
=
file_save_upload
(
'feeds'
,
array
(),
$feed_dir
))
{
file_set_status
(
$file
,
FILE_STATUS_PERMANENT
);
$values
[
'source'
]
=
$file
->
filepath
;
if
(
$file
=
file_save_upload
(
'feeds'
,
array
(
'file_validate_extensions'
=>
array
(
0
=>
$this
->
config
[
'allowed_extensions'
])),
$feed_dir
))
{
$values
[
'source'
]
=
$file
->
uri
;
}
elseif
(
empty
(
$values
[
'source'
]))
{
form_set_error
(
'feeds][source'
,
t
(
'Upload a file first.'
));
...
...
@@ -100,8 +99,8 @@ class FeedsFileFetcher extends FeedsFetcher {
// If a file has not been uploaded and $values['source'] is not empty, make
// sure that this file is within Drupal's files directory as otherwise
// potentially any file that the web server has access could be exposed.
elseif
(
!
file_check_location
(
$values
[
'source'
],
file_directory_path
())
)
{
form_set_error
(
'feeds][source'
,
t
(
'File needs to
point to a file in your Drupal file system path
.'
));
elseif
(
strpos
(
$values
[
'source'
],
'public://'
)
!==
0
)
{
form_set_error
(
'feeds][source'
,
t
(
'File needs to
reside within the site\'s file directory, its path needs to start with public://
.'
));
}
}
...
...
@@ -110,6 +109,7 @@ class FeedsFileFetcher extends FeedsFetcher {
*/
public
function
configDefaults
()
{
return
array
(
'allowed_extensions'
=>
'txt csv xml'
,
'direct'
=>
FALSE
,
);
}
...
...
@@ -119,6 +119,12 @@ class FeedsFileFetcher extends FeedsFetcher {
*/
public
function
configForm
(
&
$form_state
)
{
$form
=
array
();
$form
[
'allowed_extensions'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'Allowed file extensions'
),
'#description'
=>
t
(
'Allowed file extensions for upload.'
),
'#default_value'
=>
$this
->
config
[
'allowed_extensions'
],
);
$form
[
'direct'
]
=
array
(
'#type'
=>
'checkbox'
,
'#title'
=>
t
(
'Supply path to file directly'
),
...
...
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