fix(sync): add explicit error handling for UTF-8 decoding in iOS WebDAV plugin

Reject with DECODE_ERROR instead of silently returning empty string
when UTF-8 decoding fails on non-empty response data, preventing
the sync layer from misinterpreting decode failures as empty files.
This commit is contained in:
Johannes Millan 2026-02-02 13:34:50 +01:00
parent cc5940a257
commit 740eec68f5

View file

@ -79,8 +79,12 @@ public class WebDavHttpPlugin: CAPPlugin, CAPBridgedPlugin {
}
let bodyString: String
if let responseData = responseData {
bodyString = String(data: responseData, encoding: .utf8) ?? ""
if let responseData = responseData, !responseData.isEmpty {
guard let decoded = String(data: responseData, encoding: .utf8) else {
call.reject("Failed to decode response as UTF-8 (\(responseData.count) bytes)", "DECODE_ERROR")
return
}
bodyString = decoded
} else {
bodyString = ""
}