diff --git a/c4mate b/c4mate index 5439b19..8845b30 100755 --- a/c4mate +++ b/c4mate @@ -12,6 +12,7 @@ HOST = "http://mate.labor.koeln.ccc.de" local function utf8_decode(str) -- Replace JSON Unicode escape sequences with chars. if str == nil then return "" end + str = string.gsub(str, "\\\"", "\"") return string.gsub(str, "\\u(%x%x%x%x)", function (s) return utf8.char(tonumber(s, 16)) end) end @@ -101,6 +102,7 @@ function MatePad:parse_log(size) -- Then extract and print oldbalance, newbalance, parameter and method. -- Depending on method, print either reason or item_name. If any extraction -- fails we fail with exit code 1. + -- Note: we allow quoted quotation marks in "reason". pipe = io.popen(string.format([=[ curl %s --header "Accept: application/json" "%s/api/user/%s/log?type=json" | \ sed -n --sandbox ' @@ -128,7 +130,7 @@ sed -n ' T fail /set_balance\|transfer/{ g - s/.*"reason" *: *\(null\|"\([^"]*\)"\).*/\2/p + s/.*"reason" *: *\(null\|"\(\([^"]\|\\"\)*[^\\]\)"\).*/\2/p T fail b }