Normalize destination URI before saving file #24
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Concatenating $destination_uri and a DIRECTORY_SEPARATOR can lead to situations where the file URI has too many slashes in the scheme part, e.g. "public:///". This is then saved into the file entity, ultimately ending up in the file_managed table.
This is usually not a problem as Drupal understands this kind of URI and also normalizes this to two slashes on a number of occasions. However, versions of the focal_point module that do not use the Crop API yet will try to compare a loaded file's URI with the string saved into the file_managed table (in FocalPoint::getFromURI()) and subsequently fails to load the correct data.
This patch just puts the final destination URI through the appropriate Drupal function that cleans it up.