From 740eec68f5e2cc4ef64c857252ba1fb08c3ec48e Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Mon, 2 Feb 2026 13:34:50 +0100 Subject: [PATCH] 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. --- ios/App/App/WebDavHttpPlugin.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ios/App/App/WebDavHttpPlugin.swift b/ios/App/App/WebDavHttpPlugin.swift index 9259688f01..19e7fbb213 100644 --- a/ios/App/App/WebDavHttpPlugin.swift +++ b/ios/App/App/WebDavHttpPlugin.swift @@ -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 = "" }