Diff

util/dataforms.lua @ 11026:a086825ed73a

util.dataforms: Convert media element sizes to avoid error on Lua 5.3 The stanza API does not accept number values and threw an error due to the height and width attributes of the media element (XEP-0221). This part had no test coverage previously, explaining why it was not discovered until now.
author Kim Alvefur <zash@zash.se>
date Sun, 16 Aug 2020 12:55:55 +0200
parent 9246:397e8e5a2f1f
child 11070:f7f30a3464fe
line wrap: on
line diff
--- a/util/dataforms.lua	Thu Aug 13 17:01:05 2020 +0100
+++ b/util/dataforms.lua	Sun Aug 16 12:55:55 2020 +0200
@@ -136,7 +136,7 @@
 
 		local media = field.media;
 		if media then
-			form:tag("media", { xmlns = "urn:xmpp:media-element", height = media.height, width = media.width });
+			form:tag("media", { xmlns = "urn:xmpp:media-element", height = ("%g"):format(media.height), width = ("%g"):format(media.width) });
 			for _, val in ipairs(media) do
 				form:tag("uri", { type = val.type }):text(val.uri):up()
 			end