Changeset

10761:b53193bb21cc

util.rsm: Fix passing number as attribute
author Kim Alvefur <zash@zash.se>
date Thu, 23 Apr 2020 18:16:36 +0200
parents 10760:c9d1d9c80e1e
children 10762:4fc224c97986
files util/rsm.lua
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util/rsm.lua	Thu Apr 23 18:05:00 2020 +0200
+++ b/util/rsm.lua	Thu Apr 23 18:16:36 2020 +0200
@@ -11,9 +11,14 @@
 
 local stanza = require"util.stanza".stanza;
 local tostring, tonumber = tostring, tonumber;
+local s_format = string.format;
 local type = type;
 local pairs = pairs;
 
+local function inttostr(n)
+	return s_format("%d", n);
+end
+
 local xmlns_rsm = 'http://jabber.org/protocol/rsm';
 
 local element_parsers = {};
@@ -45,7 +50,7 @@
 local element_generators = setmetatable({
 	first = function(st, data)
 		if type(data) == "table" then
-			st:tag("first", { index = data.index }):text(data[1]):up();
+			st:tag("first", { index = inttostr(data.index) }):text(data[1]):up();
 		else
 			st:tag("first"):text(tostring(data)):up();
 		end