diff options
author | Daniel Xu <dxu@dxuuu.xyz> | 2019-08-19 19:06:52 -0700 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-08-20 16:05:20 +0900 |
commit | ea4fe713607e40cf19df37cdd0699cacba7313a3 (patch) | |
tree | 99da6e4091a99ad99d708f125fe2a1052e4cf83e /filters | |
parent | 6fcc047c3116b6ef59cae39b3beb9e815f9b62a6 (diff) | |
download | aerc-ea4fe713607e40cf19df37cdd0699cacba7313a3.tar.gz |
Strip carriage returns (^M) when filtering emails
Presumably some email servers will transform newlines into carriage return new lines to better support windows users. I can't prove this but that's the best explanation I have for my hosted email provider (fastmail). Without this patch, I was seeing annoying `^M`s at the end of every filtered line. Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Diffstat (limited to 'filters')
-rwxr-xr-x | filters/hldiff | 6 | ||||
-rwxr-xr-x | filters/plaintext | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/filters/hldiff b/filters/hldiff index a17f17b..64e95d2 100755 --- a/filters/hldiff +++ b/filters/hldiff @@ -10,6 +10,9 @@ BEGIN { } { if (hit_diff == 0) { + # Strip carriage returns from line + gsub(/\r/, "", $0) + if ($0 ~ /^diff /) { hit_diff = 1; print bright $0 reset @@ -23,6 +26,9 @@ BEGIN { print $0 } } else { + # Strip carriage returns from line + gsub(/\r/, "", $0) + if ($0 ~ /^-/) { print red $0 reset } else if ($0 ~ /^\+/) { diff --git a/filters/plaintext b/filters/plaintext index 71e33f7..cfaa170 100755 --- a/filters/plaintext +++ b/filters/plaintext @@ -5,6 +5,9 @@ BEGIN { reset = "\x1B[0m" } { + # Strip carriage returns from line + gsub(/\r/, "", $0) + if ($0 ~ /^On .*, .* wrote:/ || $0 ~ /^>+/) { print dim cyan $0 reset } else { |