# HG changeset patch # User Myhailo Danylenko # Date 1350066284 -10800 # Node ID 2b04fad2f61a24f4d26e5abb48af5e5aa39a532c # Parent 0e407455faca5bf306f3469592d9cecdf6436900 [examples] Fix non-table response handling in shortener Reported by Mikael Berthe diff -r 0e407455faca -r 2b04fad2f61a examples/mcabberrc.lua --- a/examples/mcabberrc.lua Thu Oct 11 18:11:10 2012 +0300 +++ b/examples/mcabberrc.lua Fri Oct 12 21:24:44 2012 +0300 @@ -86,7 +86,6 @@ -- COMMON SUPPORT ROUTINES --- unused :/ function shell_escape ( str ) if str then return "'" .. str:gsub ( "'", "'\\''" ) .. "'" diff -r 0e407455faca -r 2b04fad2f61a examples/shortenurl.lua --- a/examples/shortenurl.lua Thu Oct 11 18:11:10 2012 +0300 +++ b/examples/shortenurl.lua Fri Oct 12 21:24:44 2012 +0300 @@ -48,14 +48,14 @@ return true else -- eof local reply = json.decode ( replystring ) - if reply and reply.id then + if ( type ( reply ) == 'table' ) and reply.id then if jid and main.yesno ( main.option ( 'lua_shorten_post_url' ) ) then main.run ( ('say_to -q %s %s'):format ( jid, reply.id ) ) else print ( ('Shortened url: %s'):format ( reply.id ) ) end else - if type ( reply.error ) == 'table' then + if type ( reply ) == 'table' and ( type ( reply.error ) == 'table' ) then print ( ('Failed to shorten url: %u %s'):format ( reply.error.code, reply.error.message ) ) else print ( ('Failed to shorten url: Unknown response:\n%s'):format ( replystring ) )