Software /
code /
prosody
Changeset
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 |
parents | 11025:e47e7185b403 |
children | 11027:8ed6c5bdbb21 |
files | spec/util_dataforms_spec.lua util/dataforms.lua |
diffstat | 2 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/spec/util_dataforms_spec.lua Thu Aug 13 17:01:05 2020 +0100 +++ b/spec/util_dataforms_spec.lua Sun Aug 16 12:55:55 2020 +0200 @@ -106,6 +106,21 @@ name = "text-single-field", value = "text-single-value", }, + { + -- XEP-0221 + -- TODO Validate the XML produced by this. + type = "text-single", + label = "text-single-with-media-label", + name = "text-single-with-media-field", + media = { + height = 24, + width = 32, + { + type = "image/png", + uri = "data:", + }, + }, + }, }); xform = some_form:form(); end);
--- 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