Fix WebDAV upload of non-ASCII/special filenames (URL + MOVE header encoding)
Build & Release APK / build (push) Successful in 12m50s
Build & Release APK / build (push) Successful in 12m50s
Volume test (100 files) surfaced it: files with non-ASCII names (e.g. 'naïve café.txt') failed to upload — url() built a raw string, so the MOVE Destination header carried non-ASCII chars that OkHttp rejects. Now url() percent-encodes each path segment via HttpUrl.addPathSegments (also covers '&', spaces, CJK). Regression test specialAndNonAsciiNames_upload added.
This commit is contained in:
@@ -181,7 +181,13 @@ open class WebDavProvider(protected val account: CloudAccount) : CloudProvider {
|
||||
}
|
||||
}
|
||||
|
||||
protected fun url(path: String) = "$baseUrl/${path.trimStart('/')}"
|
||||
// Build a properly percent-encoded URL. addPathSegments encodes each segment (spaces,
|
||||
// ampersands, and — critically — non-ASCII like "café"), which keeps OkHttp from rejecting
|
||||
// non-ASCII in the WebDAV MOVE "Destination" header and avoids malformed request URLs.
|
||||
protected fun url(path: String): String {
|
||||
val base = baseUrl.toHttpUrlOrNull() ?: return "$baseUrl/${path.trimStart('/')}"
|
||||
return base.newBuilder().addPathSegments(path.trimStart('/')).build().toString()
|
||||
}
|
||||
|
||||
private fun parsePropfind(xml: String, parentPath: String, dropFirst: Boolean = true): List<RemoteFile> {
|
||||
val results = mutableListOf<RemoteFile>()
|
||||
|
||||
Reference in New Issue
Block a user