guard against misconfiguration of fileHost setting #2017
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.
In the process of tinkering with my CryptPad instance I discovered that accidentally including a trailing slash for the
fileHostsetting inconfig/config.jsbreaks blocks and blobs.The reason is that there are a bunch of points in the code where if
fileHostis present it will be directly prepended to those resources' file paths. When it is set tohttps://files.myinstance.website/rather thanhttps://files.myinstance.website, this doubles up on the leading slash, and lots of things break.This patch modifies the server to convert
fileHostto the expected format if it is present, and to do nothing otherwise. I suppose it could break some non-standard uses of the value, such as if files are loaded from a subpath of another domain, but as far as I know that isn't supported behaviour.Feel free to reject this PR in any case, but I figured it might save someone else the time I spent debugging the issue after my silly mistake.