浏览代码

fix: Fixes errors in prosody about string formatting and nil values. (#10037)

* fix: Fixes errors in prosody about string formatting and nil values.

error   Traceback[c2s]: /usr/lib/prosody/util/format.lua:59: invalid option '%b' to 'format'
stack traceback:

mod_polls.lua:25: attempt to index local 'data' (a nil value)
stack traceback:

* squash: Fix more formatting concatenation.
master
Дамян Минков 4 年前
父节点
当前提交
ba6247daaf
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 5 次插入5 次删除
  1. 2
    2
      resources/prosody-plugins/mod_polls.lua
  2. 3
    3
      resources/prosody-plugins/token/util.lib.lua

+ 2
- 2
resources/prosody-plugins/mod_polls.lua 查看文件

22
 		return nil;
22
 		return nil;
23
 	end
23
 	end
24
 	local data = json.decode(json_data);
24
 	local data = json.decode(json_data);
25
-	if data.type ~= "new-poll" and data.type ~= "answer-poll" then
25
+	if not data or (data.type ~= "new-poll" and data.type ~= "answer-poll") then
26
 		return nil;
26
 		return nil;
27
 	end
27
 	end
28
 	return data;
28
 	return data;
42
 module:hook("muc-room-created", function(event)
42
 module:hook("muc-room-created", function(event)
43
 	local room = event.room;
43
 	local room = event.room;
44
 	if is_healthcheck_room(room.jid) then return end
44
 	if is_healthcheck_room(room.jid) then return end
45
-	module:log("debug", "setting up polls in room "..tostring(room));
45
+	module:log("debug", "setting up polls in room %s", room.jid);
46
 	room.polls = {
46
 	room.polls = {
47
 		by_id = {};
47
 		by_id = {};
48
 		order = {};
48
 		order = {};

+ 3
- 3
resources/prosody-plugins/token/util.lib.lua 查看文件

128
     local content = self.cache:get(keyId);
128
     local content = self.cache:get(keyId);
129
     if content == nil then
129
     if content == nil then
130
         -- If the key is not found in the cache.
130
         -- If the key is not found in the cache.
131
-        module:log("debug", "Cache miss for key: "..keyId);
131
+        module:log("debug", "Cache miss for key: %s", keyId);
132
         local keyurl = path.join(self.asapKeyServer, hex.to(sha256(keyId))..'.pem');
132
         local keyurl = path.join(self.asapKeyServer, hex.to(sha256(keyId))..'.pem');
133
-        module:log("debug", "Fetching public key from: "..keyurl);
133
+        module:log("debug", "Fetching public key from: %s", keyurl);
134
         content = http_get_with_retry(keyurl, nr_retries);
134
         content = http_get_with_retry(keyurl, nr_retries);
135
         if content ~= nil then
135
         if content ~= nil then
136
             self.cache:set(keyId, content);
136
             self.cache:set(keyId, content);
138
         return content;
138
         return content;
139
     else
139
     else
140
         -- If the key is in the cache, use it.
140
         -- If the key is in the cache, use it.
141
-        module:log("debug", "Cache hit for key: "..keyId);
141
+        module:log("debug", "Cache hit for key: %s", keyId);
142
         return content;
142
         return content;
143
     end
143
     end
144
 end
144
 end

正在加载...
取消
保存