]> granicus.if.org Git - ejabberd/commitdiff
mod_http_upload: Strip newline from command output
authorHolger Weiss <holger@zedat.fu-berlin.de>
Mon, 26 Oct 2015 21:10:32 +0000 (22:10 +0100)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Mon, 26 Oct 2015 21:10:32 +0000 (22:10 +0100)
The list_to_integer/1 function doesn't cope with trailing newline
characters.

src/mod_http_upload.erl

index 40f194be20014d5a9e6ab4c4cf8aef1d0c271cf8..88ca53f7b1d4abb97a54ed7356be0b4493b4dd57 100644 (file)
@@ -838,7 +838,7 @@ code_to_message(_Code) -> <<"">>.
 identify(Path) ->
     Cmd = lists:flatten(io_lib:fwrite("identify -format \"ok %m %h %w\" ~s",
                                      [Path])),
-    Res = os:cmd(Cmd),
+    Res = string:strip(os:cmd(Cmd), right, $\n),
     case string:tokens(Res, " ") of
        ["ok", T, H, W] ->
            {ok, #media_info{
@@ -869,7 +869,7 @@ convert(Path, #media_info{type = T, width = W, height = H}) ->
                    {ok, OutPath};
                Err ->
                    ?ERROR_MSG("failed to convert ~s to ~s: ~s",
-                              [Path, OutPath, Err]),
+                              [Path, OutPath, string:strip(Err, right, $\n)]),
                    pass
            end;
        true ->