Skip to content

Commit

Permalink
Merge pull request #553 from poppastring/config-double-html-decoding
Browse files Browse the repository at this point in the history
Configure Double Decoding
  • Loading branch information
poppastring authored Apr 2, 2021
2 parents db029cb + 1497cdb commit ae80cae
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pool:

variables:
buildConfiguration: 'Release'
version: 2.32
version: 2.40

steps:
- task: UseDotNet@2
Expand Down
1 change: 1 addition & 0 deletions source/DasBlog.CLI/DasBlog.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>dasblog-core</AssemblyName>
<Version>2.40.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ public interface ISiteConfig

bool CookieConsentEnabled { get; set; }

bool EnableDoubleDecode { get; set; }

[XmlAnyElement]
XmlElement[] anyElements { get; set; }

Expand Down
1 change: 1 addition & 0 deletions source/DasBlog.Services/ConfigFile/SiteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,6 @@ public SiteConfig() { }
public string SecurityScriptSources { get; set; }

public string SecurityStyleSources { get; set; }
public bool EnableDoubleDecode { get; set; }
}
}
1 change: 1 addition & 0 deletions source/DasBlog.Services/DasBlog.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>2.40.0</Version>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DasBlog.Web.Core\DasBlog.Core.csproj" />
Expand Down
1 change: 1 addition & 0 deletions source/DasBlog.Tests/UnitTests/SiteConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,6 @@ public class SiteConfigTest : ISiteConfig
public string SecurityScriptSources { get; set; }

public string SecurityStyleSources { get; set; }
public bool EnableDoubleDecode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
}
}
1 change: 1 addition & 0 deletions source/DasBlog.Web.Core/DasBlog.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms>
<Version>2.40.0</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<NoWarn>1701;1702;NU1701</NoWarn>
Expand Down
1 change: 1 addition & 0 deletions source/DasBlog.Web.Repositories/DasBlog.Managers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms>
<Version>2.40.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NodaTime" Version="3.0.3" />
Expand Down
4 changes: 3 additions & 1 deletion source/DasBlog.Web.UI/Config/site.Development.config
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@

<SecurityStyleSources>cloud.tinymce.com;cdn.tiny.cloud;cdn.jsdelivr.net;js.nicedit.com;www.google.com;platform.twitter.com;cdn.syndication.twimg.com;fonts.googleapis.com;maxcdn.bootstrapcdn.com</SecurityStyleSources>
<SecurityScriptSources>cloud.tinymce.com;cdn.tiny.cloud;cdn.jsdelivr.net;js.nicedit.com;www.google.com;cse.google.com;cdn.syndication.twimg.com;platform.twitter.com;apis.google.com;www.google-analytics.com;www.googletagservices.com;adservice.google.com;securepubads.g.doubleclick.net;ajax.aspnetcdn.com;ssl.google-analytics.com</SecurityScriptSources>


<EnableDoubleDecode>false</EnableDoubleDecode>

<!-- Settings below this line are not currently in use -->
<!-- _________________________________________________ -->
<CommentsAllowHtml>true</CommentsAllowHtml>
Expand Down
2 changes: 2 additions & 0 deletions source/DasBlog.Web.UI/Config/site.config
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
<SecurityStyleSources>cloud.tinymce.com;cdn.tiny.cloud;cdn.jsdelivr.net;js.nicedit.com;www.google.com;platform.twitter.com;cdn.syndication.twimg.com;fonts.googleapis.com;maxcdn.bootstrapcdn.com</SecurityStyleSources>
<SecurityScriptSources>cloud.tinymce.com;cdn.tiny.cloud;cdn.jsdelivr.net;js.nicedit.com;www.google.com;cse.google.com;cdn.syndication.twimg.com;platform.twitter.com;apis.google.com;www.google-analytics.com;www.googletagservices.com;adservice.google.com;securepubads.g.doubleclick.net;ajax.aspnetcdn.com;ssl.google-analytics.com</SecurityScriptSources>

<EnableDoubleDecode>false</EnableDoubleDecode>

<!-- Settings below this line are not currently in use -->
<!-- _________________________________________________ -->
<CommentsAllowHtml>true</CommentsAllowHtml>
Expand Down
1 change: 1 addition & 0 deletions source/DasBlog.Web.UI/DasBlog.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<UserSecretsId>d3583964-0aca-4de4-9521-c74cdf42f990</UserSecretsId>
<Version>2.40.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="9.0.0" />
Expand Down
4 changes: 4 additions & 0 deletions source/DasBlog.Web.UI/Models/AdminViewModels/SiteViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ public class SiteViewModel
[Description("Help meet some of the EU General Data Protection Regulation (GDPR) requirements")]
public bool CookieConsentEnabled { get; set; }

[DisplayName("Double decode")]
[Description("")]
public bool EnableDoubleDecode { get; set; }

public bool EntryTitleAsLink { get; set; }
public bool ObfuscateEmail { get; set; }
public bool SendReferralsByEmail { get; set; }
Expand Down
15 changes: 15 additions & 0 deletions source/DasBlog.Web.UI/TagHelpers/Post/PostContentTagHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using DasBlog.Core.Extensions;
using DasBlog.Services;
using DasBlog.Web.Models.BlogViewModels;
using Microsoft.AspNetCore.Razor.TagHelpers;
using System.Threading.Tasks;
using System.Web;

namespace DasBlog.Web.TagHelpers.Post
{
Expand All @@ -13,9 +15,22 @@ public class PostContentTagHelper : TagHelper

public int ContentLength { get; set; } = 100000;

private readonly IDasBlogSettings dasBlogSettings;

public PostContentTagHelper(IDasBlogSettings dasBlogSettings)
{
this.dasBlogSettings = dasBlogSettings;
}

public override void Process(TagHelperContext context, TagHelperOutput output)
{
var content = Post.Content;

if(dasBlogSettings.SiteConfiguration.EnableDoubleDecode)
{
content = HttpUtility.HtmlDecode(Post.Content);
}

output.TagName = "div";
output.TagMode = TagMode.StartTagAndEndTag;
output.Attributes.SetAttribute("class", "dbc-post-content");
Expand Down
7 changes: 7 additions & 0 deletions source/DasBlog.Web.UI/Views/Admin/Settings.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,13 @@

</div>

<div class="dbc-form-check row">

@Html.LabelFor(m => @Model.SiteConfig.EnableDoubleDecode, null, new { @class = "dbc-col-form-label col-3" })
@Html.CheckBoxFor(m => @Model.SiteConfig.EnableDoubleDecode, new { @class = "dbc-form-check-input" })

</div>

<h3>Internal</h3>

<div class="dbc-form-group row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>2.40.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit ae80cae

Please sign in to comment.