Unverified Commit 6e1d970a authored by larowlan's avatar larowlan
Browse files

Issue #3160015 by quietone, mikelutz: Don't remove all slashes from filepath in file.php

parent 6ffbfe25
......@@ -87,7 +87,7 @@ public function prepareRow(Row $row) {
// At this point, $path could be an absolute path or a relative path,
// depending on how the scheme's variable was set. So we need to shear out
// the source_base_path in order to make them all relative.
$path = str_replace($this->configuration['constants']['source_base_path'], NULL, $path);
$path = preg_replace('#' . preg_quote($this->configuration['constants']['source_base_path']) . '#', '', $path, 1);
$row->setSourceProperty('filepath', $path);
return parent::prepareRow($row);
}
......
......@@ -158,6 +158,36 @@ public function providerSource() {
'scheme' => 'public',
];
// Test getting only private files with absolute file private path.
$tests[3]['source_data'] = $tests[0]['source_data'];
$tests[3]['source_data']['variable'][1] = [
'name' => 'file_private_path',
'value' => serialize('/home/lillian/subdomains/u2/u2-private-files'),
];
$tests[3]['expected_data'] = [
[
'fid' => '1',
'uid' => '1',
'filename' => 'cube.jpeg',
'uri' => 'private://cube.jpeg',
'filemime' => 'image/jpeg',
'filesize' => '3620',
'status' => '1',
'timestamp' => '1421727515',
'filepath' => 'home/lillian/subdomains/u2/u2-private-files/cube.jpeg',
],
];
// Do an automatic count.
$tests[3]['expected_count'] = NULL;
// Set up plugin configuration.
$tests[3]['configuration'] = [
'constants' => [
'source_base_path' => '/',
],
'scheme' => 'private',
];
return $tests;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment