aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2017-06-06 18:19:18 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2017-06-06 18:19:18 +0200
commit621642a33b947cc29fa1aa48e5268385a9d582b3 (patch)
tree23e361279c00b8d9d39482819edd4ac8b48465aa
parent9a0ea281fb40292636146031a560065e9fa7622b (diff)
downloaddotfiles-621642a33b947cc29fa1aa48e5268385a9d582b3.tar.gz
dotfiles-621642a33b947cc29fa1aa48e5268385a9d582b3.zip
lumail2 add Content-Type to the headers
-rw-r--r--config/lumail2/lumail2.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/config/lumail2/lumail2.lua b/config/lumail2/lumail2.lua
index 8e66daf..8466863 100644
--- a/config/lumail2/lumail2.lua
+++ b/config/lumail2/lumail2.lua
@@ -200,3 +200,29 @@ do
end
end
+--
+-- Add Content-Type to the headers before sending
+--
+function on_message_send(path)
+ local content = {}
+ local added = false
+ local is_header = "^%a+: .*"
+ for l in io.lines(path) do
+ -- Find the last header.
+ if not added
+ and content[#content] and string.match(content[#content], is_header)
+ and not string.match(l, is_header)
+ then
+ -- Append Content-Type to the headers.
+ table.insert(content, "Content-Type: text/plain; charset=UTF-8\n")
+ added = true
+ end
+ table.insert(content, l.."\n")
+ end
+
+ -- write the new content
+ local m = io.open(path, "w")
+ m:write(unpack(content))
+ m:close()
+end
+