Github user Humbedooh commented on the issue:
https://github.com/apache/incubator-ponymail/issues/371
Because of
https://github.com/apache/incubator-ponymail/commit/117db841331bb93d71763fe361d4455d71e716b0
which converts into base64 on some occasions.
This patch is more complete:
~~~
--- a/site/api/source.lua
+++ b/site/api/source.lua
@@ -23,6 +23,15 @@ local user = require 'lib/user'
local cross = require 'lib/cross'
local utils = require 'lib/utils'
+function is_base64(msg)
+ if #msg % 4 == 0 then
+ if not msg:match("([^a-zA-Z0-9+=/])") then
+ return true
+ end
+ end
+ return false
+end
+
function handle(r)
-- content is currently utf-8, see #367
cross.contentType(r, "text/plain; charset=utf-8")
@@ -46,6 +55,10 @@ function handle(r)
if aaa.canAccessDoc(r, doc, account) then
local doc_raw = elastic.get('mbox_source', doc.request_id)
if doc_raw then
+ -- If this could be base64, try to convert it.
+ if is_base64(doc_raw.source) then
+ pcall(function() doc_raw.source =
r:base64_decode(doc_raw.source) end)
+ end
r:puts(doc_raw.source)
else
r:puts("Could not find the email source, sorry!")
~~~
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---