mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-17 16:37:43 +00:00
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:
parent
cc5940a257
commit
740eec68f5
1 changed files with 6 additions and 2 deletions
|
|
@ -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 = ""
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue