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
1b14a060
Commit
1b14a060
authored
9 years ago
by
twistor
Committed by
Chris Leppanen
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #2510788 by twistor: Remove query string from path in FeedsEnclosure.
parent
8f278023
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
plugins/FeedsParser.inc
+7
-3
7 additions, 3 deletions
plugins/FeedsParser.inc
tests/feeds_mapper_file.test
+8
-0
8 additions, 0 deletions
tests/feeds_mapper_file.test
with
15 additions
and
3 deletions
plugins/FeedsParser.inc
+
7
−
3
View file @
1b14a060
...
...
@@ -315,7 +315,7 @@ class FeedsEnclosure extends FeedsElement {
*/
public
function
setAllowedExtensions
(
$extensions
)
{
// Normalize whitespace so that empty extensions are not allowed.
$this
->
allowedExtensions
=
trim
(
preg_replace
(
'/\s+/'
,
' '
,
$extensions
));
$this
->
allowedExtensions
=
drupal_strtolower
(
trim
(
preg_replace
(
'/\s+/'
,
' '
,
$extensions
))
)
;
}
/**
...
...
@@ -371,7 +371,11 @@ class FeedsEnclosure extends FeedsElement {
return
$this
->
safeFilename
;
}
$filename
=
rawurldecode
(
drupal_basename
(
$this
->
getValue
()));
// Strip any query string or fragment from file name.
list
(
$filename
)
=
explode
(
'?'
,
$this
->
getValue
());
list
(
$filename
)
=
explode
(
'#'
,
$filename
);
$filename
=
rawurldecode
(
drupal_basename
(
$filename
));
if
(
module_exists
(
'transliteration'
))
{
require_once
drupal_get_path
(
'module'
,
'transliteration'
)
.
'/transliteration.inc'
;
...
...
@@ -385,7 +389,7 @@ class FeedsEnclosure extends FeedsElement {
$extension
=
FALSE
;
}
else
{
$extension
=
substr
(
$filename
,
strrpos
(
$filename
,
'.'
)
+
1
);
$extension
=
drupal_strtolower
(
substr
(
$filename
,
strrpos
(
$filename
,
'.'
)
+
1
)
)
;
}
if
(
!
$extension
||
!
in_array
(
$extension
,
explode
(
' '
,
$this
->
allowedExtensions
),
TRUE
))
{
...
...
This diff is collapsed.
Click to expand it.
tests/feeds_mapper_file.test
+
8
−
0
View file @
1b14a060
...
...
@@ -267,6 +267,14 @@ class FeedsMapperFileTestCase extends FeedsMapperTestCase {
$message
=
t
(
'The file @file has an invalid extension.'
,
array
(
'@file'
=>
$filename
));
$this
->
assertTrue
(
db_query
(
"SELECT 1 FROM
{
watchdog
}
WHERE message = :message"
,
array
(
':message'
=>
$message
))
->
fetchField
());
}
// Test that query string and fragments are removed.
$enclosure
=
new
FeedsEnclosure
(
'http://example.com/image.jpg?thing=stuff'
,
'text/plain'
);
$this
->
assertEqual
(
$enclosure
->
getLocalValue
(),
'image.jpg'
);
$enclosure
=
new
FeedsEnclosure
(
'http://example.com/image.jpg#stuff'
,
'text/plain'
);
$this
->
assertEqual
(
$enclosure
->
getLocalValue
(),
'image.jpg'
);
$enclosure
=
new
FeedsEnclosure
(
'http://example.com/image.JPG?thing=stuff#stuff'
,
'text/plain'
);
$this
->
assertEqual
(
$enclosure
->
getLocalValue
(),
'image.JPG'
);
}
/**
...
...
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