Use more memory efficient StripHtml method

This commit is contained in:
Sebastiaan Janssen
2017-01-17 18:58:53 +01:00
parent a9435022d5
commit 705b8ec6a6
6 changed files with 7 additions and 6 deletions
@@ -68,7 +68,7 @@ namespace OurUmbraco.NotificationsCore.Notifications
var domain = _details.SelectSingleNode("//domain").InnerText;
var body = _details.SelectSingleNode("//body").InnerText;
body = string.Format(body, topic.Title, "https://" + domain + url + "#comment-" + comment.Id, memberName,
HttpUtility.HtmlDecode(umbraco.library.StripHtml(comment.Body)));
HttpUtility.HtmlDecode(comment.Body.StripHtml()));
var mailMessage = new MailMessage
{
@@ -68,7 +68,7 @@ namespace OurUmbraco.NotificationsCore.Notifications
var body = _details.SelectSingleNode("//body").InnerText;
body = string.Format(body, forum.Name, "https://" + domain + url, memberName, topic.Title,
HttpUtility.HtmlDecode(umbraco.library.StripHtml(topic.Body)));
HttpUtility.HtmlDecode(topic.Body.StripHtml()));
var mailMessage = new MailMessage
{
+2 -1
View File
@@ -5,6 +5,7 @@ using System.Linq;
using System.Text.RegularExpressions;
using Examine;
using Examine.LuceneEngine;
using Umbraco.Core;
using Umbraco.Core.Logging;
namespace OurUmbraco.Our.Examine
@@ -45,7 +46,7 @@ namespace OurUmbraco.Our.Examine
lines.AddRange(File.ReadAllLines(file.FullName));
var body = lines.Any()
? umbraco.library.StripHtml(RemoveSpecialCharacters(string.Join("", lines)))
? RemoveSpecialCharacters(string.Join("", lines)).StripHtml()
: string.Empty;
var firstHeadline = lines.FirstOrDefault(x => x.StartsWith("#"));
+1 -1
View File
@@ -23,7 +23,7 @@ namespace OurUmbraco.Our.Examine
foreach (var currentComment in topic.Comments.Where(c => c.IsSpam == false))
commentText += currentComment.Body;
var body = library.StripHtml(topic.Body + commentText);
var body = (topic.Body + commentText).StripHtml();
simpleDataSet.NodeDefinition.NodeId = id;
simpleDataSet.NodeDefinition.Type = indexType;
@@ -216,7 +216,7 @@ namespace OurUmbraco.Our.Examine
//remove the current version field from the lucene doc
e.Document.RemoveField("body");
//add a 'body' field with stripped html
e.Document.Add(new Field("body", library.StripHtml(e.Fields["body"]), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
e.Document.Add(new Field("body", e.Fields["body"].StripHtml(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
}
//If there is a versions field, we'll split it and index the same field on each version
+1 -1
View File
@@ -99,7 +99,7 @@ namespace OurUmbraco.Project
public static string StripHtmlAndLimit(this String str, int chars)
{
str = umbraco.library.StripHtml(str);
str = str.StripHtml();
if (str.Length > chars)
str = str.Substring(0, chars);