Comparison

util/xmppstream.lua @ 10093:1266a63ba567

util.xmppstream: Inherit xml:lang from stream to stanzas (fixes #1401)
author Kim Alvefur <zash@zash.se>
date Sun, 28 Jul 2019 01:17:44 +0200
parent 9071:db61e33bbd41
child 11358:ebbf8dca33d2
comparison
equal deleted inserted replaced
10091:bd547587f48c 10093:1266a63ba567
61 stream_tag = stream_ns..ns_separator..stream_tag; 61 stream_tag = stream_ns..ns_separator..stream_tag;
62 end 62 end
63 local stream_error_tag = stream_ns..ns_separator..(stream_callbacks.error_tag or "error"); 63 local stream_error_tag = stream_ns..ns_separator..(stream_callbacks.error_tag or "error");
64 64
65 local stream_default_ns = stream_callbacks.default_ns; 65 local stream_default_ns = stream_callbacks.default_ns;
66
67 local stream_lang = "en";
66 68
67 local stack = {}; 69 local stack = {};
68 local chardata, stanza = {}; 70 local chardata, stanza = {};
69 local stanza_size = 0; 71 local stanza_size = 0;
70 local non_streamns_depth = 0; 72 local non_streamns_depth = 0;
99 stanza_size = self:getcurrentbytecount(); 101 stanza_size = self:getcurrentbytecount();
100 end 102 end
101 if session.notopen then 103 if session.notopen then
102 if tagname == stream_tag then 104 if tagname == stream_tag then
103 non_streamns_depth = 0; 105 non_streamns_depth = 0;
106 stream_lang = attr["xml:lang"] or stream_lang;
104 if cb_streamopened then 107 if cb_streamopened then
105 if lxp_supports_bytecount then 108 if lxp_supports_bytecount then
106 cb_handleprogress(stanza_size); 109 cb_handleprogress(stanza_size);
107 stanza_size = 0; 110 stanza_size = 0;
108 end 111 end
176 if #stack == 0 then 179 if #stack == 0 then
177 if lxp_supports_bytecount then 180 if lxp_supports_bytecount then
178 cb_handleprogress(stanza_size); 181 cb_handleprogress(stanza_size);
179 end 182 end
180 stanza_size = 0; 183 stanza_size = 0;
184 if stanza.attr["xml:lang"] == nil then
185 stanza.attr["xml:lang"] = stream_lang;
186 end
181 if tagname ~= stream_error_tag then 187 if tagname ~= stream_error_tag then
182 cb_handlestanza(session, stanza); 188 cb_handlestanza(session, stanza);
183 else 189 else
184 cb_error(session, "stream-error", stanza); 190 cb_error(session, "stream-error", stanza);
185 end 191 end