Problem/Motivation
If the user enters a public or private document root on the Credential form that only contains slashes then all slashes are removed from the filepath resulting in an invalid path.
$path = str_replace($this->configuration['constants']['source_base_path'], NULL, $path);
Discovered while working on #2925899: MigrateUpgradeImportBatch does not use source_private_file_path & source_base_path correctly, making it impossible to have public & private files in separate locations
Proposed resolution
If the user input is only slashes then skip the str_replace.
Remaining tasks
Patch, add tests, review, commit
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 3160015-6.patch | 2.25 KB | benjifisher |
| #6 | 3160015-6.patch | 2.25 KB | quietone |
| #6 | interdiff-3-6.txt | 2.04 KB | quietone |
| #3 | 3160015-2.patch | 2.32 KB | quietone |
| #3 | 3160015-2-fail.patch | 1.4 KB | quietone |
Comments
Comment #2
benjifisherPerhaps #3151363: Double // in file paths is related. We might even combine the two issues.
Comment #3
quietone commentedAnd a patch with test. No interdiff because they are so small.
personal note:
It is with sadness that I could not use '/home/hypatia' (Hypatia) in the test because of the spellchecker. I found that 'ada' and 'barbara' was accepted but I wanted to recognize other women. So, I settled on '/home/lillian' for Lillian Moller Gilbreth.
Yes, I could have used 'foo'. But I value recognizing those who came before us.
What is most concerning to me is that the accepted names are very culture specific.
Comment #5
mikelutzI don't think we want to skip the string replace, I think we want
preg_replace('/' . preg_quote($this->configuration['constants']['source_base_path']) . '/', '', $path, 1);? We still want to remove the first slash here.Comment #6
quietone commentedAgree, that is better.
Comment #7
mikelutzThanks! looks better!
Comment #9
larowlanCommitted 6e1d970 and pushed to 9.1.x. Thanks!
Flagging for possible backport
Comment #10
quietone commentedRetested with 9.0.x and tests still passing.
Comment #11
benjifisherI am re-uploading the patch from #6 because it looks as though the tests are still running it against 9.1.
Comment #13
quietone commentedUnrelated failure in Media_library.Drupal\Tests\media_library\FunctionalJavascript\EntityReferenceWidgetTest
Comment #14
alexpott+1 to backporting this.
Comment #16
larowlanbackported to 9.0.x