Desktop,Mobile,Cli: Fixes #10608: WebDAV synchronisation not working because of URL encoding differences #11076
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.
Fixes #10608
Summary
When using the WebDAV sync target the items data returned by the server doesn't encode URI elements of email (see test example at
[email protected]
), but it will encode URI folders with spaces (joplin files
turns intojoplin%20files
).When using the WebDAV sync target, synchronisation can fail because of the difference between the encodings of the data returned by the WebDAV API (in this case specific to the
d:href
property) and therelativeBaseUrl
property.Differences that I noticed:
d:href
does not encode@
butrelativeBaseUrl
doesrelativeBaseUrl
does not encode whitespace whiled:href
doesI think the best solution for this would be to fix this encoding difference before it reaches the
hrefToRelativePath_
function (where this PR is fixing the issue) but since it is near the feature freeze I thought that the simplesest solution would be better.Testing
I added automated tests to the
hrefToRelativePath_
function onfile-api-driver-webdav.test.ts
.To create the tests I made some real world testing described bellow:
1 - Created a
Joplin
folder on my base WebDAV server2 - Added WebDav as my sync target, my sync target URL has my
[email protected]
address on it3 - Created some notebooks and notes and tried to synch
4 - Found the error reported in the issue because
@
on email address is encoded to%40
onrelativeBaseUrl
value, but thed:href
property with the relative path to the file doesn't encode itOther test case:
1 - Created a
joplin files
folder on my base WebDAV server2 - Added WebDav as my sync target, my sync target URL has my
[email protected]
address on it3 - Created some notebooks and notes and tried to synch
4 - Now I found that
d:href
encodes whites spaces whilerelativeBaseUrl
does not