Skip to content

Commit

Permalink
[#8051] Fix issue that caused breakage in modFileMediaSource
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun McCormick committed Jun 14, 2012
1 parent c286e64 commit 975675e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions core/model/modx/modfilehandler.class.php
Expand Up @@ -111,12 +111,9 @@ public function getBaseUrl() {
* @return string The sanitized path
*/
public function sanitizePath($path) {
$replace = array('../' => '', './' => '', '\\' => '/', '//' => '/');
foreach ($replace as $from => $to) {
while (stristr($from,$path)) {
$path = str_replace($from,$to,$path);
}
}
$path = str_replace(array('../', './'), '', $path);
$path = strtr($path, '\\', '/');
$path = str_replace('//', '/', $path);
return $path;
}

Expand Down

2 comments on commit 975675e

@Lyubomir71
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in row #116 (red color) change place variable $from and $path, like that:

while (stristr($path,$from)) {

Thus the function:

public function sanitizePath($path) {
$replace = array('../' => '', './' => '', '' => '/', '//' => '/');
foreach ($replace as $from => $to) {
while (stristr($path,$from)) {
$path = str_replace($from,$to,$path);
}
}
return $path;
}

work normally

@opengeek
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was solved without the recursion necessary; see 10248d0#L1R114

Please sign in to comment.