Skip to content

Commit b60e1fc

Browse files
committed
FIX: Add HTML encoding to body of topic/reply when displaying
1 parent 57d7c38 commit b60e1fc

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

Dnn.CommunityForums/Entities/ReplyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,11 @@ public string GetProperty(string propertyName, string format, System.Globalizati
401401
}
402402

403403
case "summary":
404-
return PropertyAccess.FormatString(Utilities.EncodeBrackets(length > 0 && this.Summary.Length > length ? this.Summary.Substring(0, length) : this.Summary), format);
404+
return PropertyAccess.FormatString(Utilities.EncodeBrackets(System.Web.HttpUtility.HtmlEncode(length > 0 && this.Summary.Length > length ? this.Summary.Substring(0, length) : this.Summary)), format);
405405
case "body":
406-
return PropertyAccess.FormatString(length > 0 && this.Content.Body.Length > length ? this.Content.Body.Substring(0, length) : this.Content.Body, Utilities.EncodeBrackets(format));
406+
return PropertyAccess.FormatString(Utilities.EncodeBrackets(System.Web.HttpUtility.HtmlEncode(length > 0 && this.Content.Body.Length > length ? this.Content.Body.Substring(0, length) : this.Content.Body)), format);
407407
case "bodytitle":
408-
return PropertyAccess.FormatString(Utilities.EncodeBrackets(GetTopicTitle(this.Content.Body)), format);
408+
return PropertyAccess.FormatString(Utilities.EncodeBrackets(System.Web.HttpUtility.HtmlEncode(GetTopicTitle(this.Content.Body))), format);
409409
case "link":
410410
{
411411
string sTopicURL = new ControlUtils().BuildUrl(this.Forum.PortalSettings.PortalId, this.GetTabId(), this.Forum.ModuleId, this.Forum.ForumGroup.PrefixURL, this.Forum.PrefixURL, this.Forum.ForumGroupId, this.Forum.ForumID, this.TopicId, this.Topic.TopicUrl, -1, -1, string.Empty, 1, this.ContentId, this.Forum.SocialGroupId);

Dnn.CommunityForums/Entities/TopicInfo.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -736,15 +736,15 @@ public string GetProperty(string propertyName, string format, System.Globalizati
736736

737737
return string.Empty;
738738
case "bodytitle":
739-
return PropertyAccess.FormatString(Utilities.EncodeBrackets(GetTopicTitle(this.Content.Body)), format);
739+
return PropertyAccess.FormatString(Utilities.EncodeBrackets(System.Web.HttpUtility.HtmlEncode(GetTopicTitle(this.Content.Body))), format);
740740
case "summary":
741741
return PropertyAccess.FormatString(
742-
Utilities.EncodeBrackets(
742+
Utilities.EncodeBrackets(System.Web.HttpUtility.HtmlEncode(
743743
!string.IsNullOrEmpty(this.Summary)
744744
? length > 0 && this.Summary.Length > length ? this.Summary.Substring(0, length) : this.Summary
745-
: length > 0 && this.Content.Body.Length > length ? this.Content.Body.Substring(0, length) : this.Content.Body), format);
745+
: length > 0 && this.Content.Body.Length > length ? this.Content.Body.Substring(0, length) : this.Content.Body)), format);
746746
case "body":
747-
return PropertyAccess.FormatString(Utilities.EncodeBrackets(length > 0 && this.Content.Body.Length > length ? this.Content.Body.Substring(0, length) : this.Content.Body), format);
747+
return PropertyAccess.FormatString(Utilities.EncodeBrackets(System.Web.HttpUtility.HtmlEncode(length > 0 && this.Content.Body.Length > length ? this.Content.Body.Substring(0, length) : this.Content.Body)), format);
748748
case "lastreplyid":
749749
return PropertyAccess.FormatString(this.LastReplyId.ToString(), format);
750750
case "replycount":

Dnn.CommunityForums/ReleaseNotes.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,14 @@
7070
<li>NEW: Adds Recycle Bin to be able to restore (soft-)deleted topics and replies (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/pull/1531">PR# 1531</a>)</li>
7171
<li>NEW: Adds an avatar injection service to populate avatars (currently using Gravatar) for forums users who haven't set up their own DNN profile picture/avatar. (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/pull/1446">PR# 1446</a>)</li>
7272
<!--
73-
<li>NEW: (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/pull/TBD">PR# TBD</a>)</li>
74-
73+
<li>NEW: (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/pull/TBD">PR# TBD</a>)</li>
7574
<li>UPDATE: (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/issues/">Issue </a>)</li>
76-
-->
75+
-->
76+
<li>UPDATE: Improved handling of XML & HTML in posts (<a href="https://github.com/DNNCommunity/Dnn.CommunityForums/issues/1385">Issue 1385</a>)</li>
77+
78+
<!--
7779
<li>None at this time.</li>
80+
-->
7881
</ul>
7982

8083
<h4>Bug Fixes</h4>

0 commit comments

Comments
 (0)