v1.0.77: fix WebDAV filename decode — literal '+' (e.g. 6103+.pdf) no longer 404s
Build & Release APK / build (push) Successful in 13m10s
Build & Release APK / build (push) Successful in 13m10s
PROPFIND href segments were decoded with java.net.URLDecoder, which applies the form-encoding rule '+' -> space. A file named '6103+.pdf' was read as '6103 .pdf', so every GET/DELETE requested '6103%20.pdf' and 404'd forever — that one file could never sync. Replaced with decodeWebDavSegment(): decodes %XX only, leaves '+' literal. Covered by WebDavDecodeTest (7 tests).
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package com.syncflow.data.providers.webdav
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Path-segment decoding must not apply the form-encoding `+` → space rule.
|
||||
* Regression coverage for the "6103+.pdf" file that 404'd forever.
|
||||
*/
|
||||
class WebDavDecodeTest {
|
||||
|
||||
@Test fun `literal plus is preserved (the 6103 bug)`() =
|
||||
assertEquals("6103+.pdf", decodeWebDavSegment("6103+.pdf"))
|
||||
|
||||
@Test fun `percent-encoded plus decodes to a plus`() =
|
||||
assertEquals("6103+.pdf", decodeWebDavSegment("6103%2B.pdf"))
|
||||
|
||||
@Test fun `percent-twenty decodes to a space`() =
|
||||
assertEquals("my file.pdf", decodeWebDavSegment("my%20file.pdf"))
|
||||
|
||||
@Test fun `space and plus stay distinct`() {
|
||||
assertEquals("a b", decodeWebDavSegment("a%20b")) // %20 -> space
|
||||
assertEquals("a+b", decodeWebDavSegment("a+b")) // literal + stays +, NOT space
|
||||
}
|
||||
|
||||
@Test fun `utf8 percent sequences decode (persian)`() =
|
||||
assertEquals("عکس.jpg", decodeWebDavSegment("%D8%B9%DA%A9%D8%B3.jpg"))
|
||||
|
||||
@Test fun `plain ascii passes through`() =
|
||||
assertEquals("photo.jpg", decodeWebDavSegment("photo.jpg"))
|
||||
|
||||
@Test fun `trailing bare percent is left literal`() =
|
||||
assertEquals("50%", decodeWebDavSegment("50%"))
|
||||
}
|
||||
Reference in New Issue
Block a user