From 54314dda65600cb24138c8353a37875cc2c510ae Mon Sep 17 00:00:00 2001 From: dhruvb14 Date: Sat, 28 Jan 2017 00:19:56 -0500 Subject: [PATCH 1/2] Partial fix for broken HR tag's in Email... --- Ombi.Services/Jobs/RecentlyAdded.cs | 29 ++++++++++--------- .../Jobs/Templates/RecentlyAddedTemplate.html | 4 +-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Ombi.Services/Jobs/RecentlyAdded.cs b/Ombi.Services/Jobs/RecentlyAdded.cs index 8ac7b6743..563dd35a5 100644 --- a/Ombi.Services/Jobs/RecentlyAdded.cs +++ b/Ombi.Services/Jobs/RecentlyAdded.cs @@ -200,16 +200,17 @@ namespace Ombi.Services.Jobs html = template.LoadTemplate(sb.ToString()); Log.Debug("Loaded the template"); } - - Send(newletterSettings, html, plexSettings, testEmail); + string escapedHtml = new string(html.Where(c => !char.IsControl(c)).ToArray()); + Log.Debug(escapedHtml); + Send(newletterSettings, escapedHtml, plexSettings, testEmail); } private void GenerateMovieHtml(List movies, PlexSettings plexSettings, StringBuilder sb) { var orderedMovies = movies.OrderByDescending(x => x?.addedAt.UnixTimeStampToDateTime()).ToList() ?? new List(); - sb.Append("

New Movies:



"); + sb.Append("

New Movies:



"); sb.Append( ""); foreach (var movie in orderedMovies) @@ -259,13 +260,13 @@ namespace Ombi.Services.Jobs } } - sb.Append("


"); + sb.Append("

"); } private void GenerateMovieHtml(List movies, PlexSettings plexSettings, StringBuilder sb) { var orderedMovies = movies.OrderByDescending(x => x?.addedAt.UnixTimeStampToDateTime()).ToList() ?? new List(); - sb.Append("

New Movies:



"); + sb.Append("

New Movies:



"); sb.Append( ""); foreach (var movie in orderedMovies) @@ -315,14 +316,14 @@ namespace Ombi.Services.Jobs } } - sb.Append("


"); + sb.Append("

"); } private void GenerateTvHtml(List tv, PlexSettings plexSettings, StringBuilder sb) { var orderedTv = tv.OrderByDescending(x => x?.addedAt.UnixTimeStampToDateTime()).ToList(); // TV - sb.Append("

New Episodes:



"); + sb.Append("

New Episodes:



"); sb.Append( ""); foreach (var t in orderedTv) @@ -375,14 +376,14 @@ namespace Ombi.Services.Jobs EndLoopHtml(sb); } } - sb.Append("


"); + sb.Append("

"); } private void GenerateTvHtml(List tv, PlexSettings plexSettings, StringBuilder sb) { var orderedTv = tv.OrderByDescending(x => x?.addedAt.UnixTimeStampToDateTime()).ToList(); // TV - sb.Append("

New Episodes:



"); + sb.Append("

New Episodes:



"); sb.Append( ""); foreach (var t in orderedTv) @@ -435,7 +436,7 @@ namespace Ombi.Services.Jobs EndLoopHtml(sb); } } - sb.Append("


"); + sb.Append("

"); } private void Send(NewletterSettings newletterSettings, string html, PlexSettings plexSettings, bool testEmail = false) @@ -516,10 +517,12 @@ namespace Ombi.Services.Jobs private void EndLoopHtml(StringBuilder sb) { + //NOTE: BR have to be in TD's as per html spec or it will be put outside of the table... + //Source: http://stackoverflow.com/questions/6588638/phantom-br-tag-rendered-by-browsers-prior-to-table-tag + sb.Append("
"); + sb.Append("
"); + sb.Append("
"); sb.Append(""); - sb.Append("
"); - sb.Append("
"); - sb.Append("
"); sb.Append(""); } diff --git a/Ombi.Services/Jobs/Templates/RecentlyAddedTemplate.html b/Ombi.Services/Jobs/Templates/RecentlyAddedTemplate.html index 2229df38c..3bdc22e42 100644 --- a/Ombi.Services/Jobs/Templates/RecentlyAddedTemplate.html +++ b/Ombi.Services/Jobs/Templates/RecentlyAddedTemplate.html @@ -157,14 +157,14 @@ - {@RECENTLYADDED} + - + {@RECENTLYADDED}