]> granicus.if.org Git - ejabberd/commitdiff
Use xml:lang from stanza when it's missing in <command/> element
authorEvgeny Khramtsov <ekhramtsov@process-one.net>
Sat, 6 Apr 2019 15:27:28 +0000 (18:27 +0300)
committerEvgeny Khramtsov <ekhramtsov@process-one.net>
Sat, 6 Apr 2019 15:27:28 +0000 (18:27 +0300)
Thanks to Philipp Hörist for spotting this

src/mod_adhoc.erl

index c77d6a047a7b3ffc9f7988c283eaa0914074ef24..f6a61fe03285d9ff2ffc8b7518503ef2badfd8b0 100644 (file)
@@ -215,10 +215,10 @@ process_adhoc_request(#iq{from = From, to = To,
     Res = case Type of
              local ->
                  ejabberd_hooks:run_fold(adhoc_local_commands, Host, empty,
-                                         [From, To, SubEl]);
+                                         [From, To, fix_lang(Lang, SubEl)]);
              sm ->
                  ejabberd_hooks:run_fold(adhoc_sm_commands, Host, empty,
-                                         [From, To, SubEl])
+                                         [From, To, fix_lang(Lang, SubEl)])
          end,
     case Res of
        ignore ->
@@ -266,6 +266,11 @@ ping_command(_Acc, _From, _To,
     end;
 ping_command(Acc, _From, _To, _Request) -> Acc.
 
+fix_lang(Lang, #adhoc_command{lang = <<>>} = Cmd) ->
+    Cmd#adhoc_command{lang = Lang};
+fix_lang(_, Cmd) ->
+    Cmd.
+
 depends(_Host, _Opts) ->
     [].