diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-11-03 11:27:52 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-11-03 11:27:52 +0100 |
commit | 0dd0114a9d115819cb31a3903da742b09616f9f0 (patch) | |
tree | 8d2f6ad1c8597ea7e59f6f90bb8d35ff49eac941 | |
parent | 4b1a074c95a674f2da154ee627e053db550cdd9d (diff) |
luci-base: fix empty reply format in ubus gateway fallback code
The ubus gateway fallback code incorrectly formatted ubus replies
containing no payload data when forwarding them via HTTP, leading
to `TypeError: Unexpected reply data format` errors in at least
the `luci.fs` class when receiving replies without payload.
Fix this issue by ensuring that the result array never contains
a `null` value for the payload, send an one-element array containing
just the status code in this case instead.
Fixes: #6074
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | modules/luci-base/ucode/controller/admin/index.uc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/luci-base/ucode/controller/admin/index.uc b/modules/luci-base/ucode/controller/admin/index.uc index 16a74abc46..f0f7c7fd4d 100644 --- a/modules/luci-base/ucode/controller/admin/index.uc +++ b/modules/luci-base/ucode/controller/admin/index.uc @@ -23,8 +23,10 @@ function ubus_reply(id, data, code, errmsg) { reply.error = { code, message: errmsg }; else if (type(code) == 'object') reply.result = code; - else + else if (data != null) reply.result = [ code, data ]; + else + reply.result = [ code ]; return reply; } |