Skip to content

Commit c689580

Browse files
authored
Merge commit from fork
Don't allow HTML response content in Prompt data
2 parents 8ceef37 + eaf6ff4 commit c689580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+27556
-19997
lines changed

DNN Platform/DotNetNuke.Abstractions/Prompt/ICommand.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// See the LICENSE file in the project root for more information
44
namespace DotNetNuke.Abstractions.Prompt
55
{
6-
/// <summary>This is used to retrieve and keep a list of all commands found in the installation.</summary>
6+
/// <summary>This contains information about a Prompt command available in the installation.</summary>
77
public interface ICommand
88
{
99
/// <summary>Gets or sets the name of the command.</summary>
@@ -13,15 +13,10 @@ public interface ICommand
1313
string Description { get; set; }
1414

1515
/// <summary>Gets or sets the category to which this command belongs.</summary>
16-
/// <remarks>
17-
/// This is used to group the list of commands when a user requests this.
18-
/// </remarks>
16+
/// <remarks>This is used to group the list of commands when a user requests this.</remarks>
1917
string Category { get; set; }
2018

21-
/// <summary>
22-
/// Gets or sets the key that is used to lookup the command internally
23-
/// (= upper cased command name).
24-
/// </summary>
19+
/// <summary>Gets or sets the key that is used to look up the command internally (i.e. the upper-cased command name).</summary>
2520
string Key { get; set; }
2621

2722
/// <summary>Gets or sets the assembly version of the assembly containing the command.</summary>

DNN Platform/DotNetNuke.Abstractions/Prompt/ICommandOption.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// See the LICENSE file in the project root for more information
44
namespace DotNetNuke.Abstractions.Prompt
55
{
6-
/// <summary>This is used in the ICommandHelp to send a list of command parameters to the client for explanatory help.</summary>
6+
/// <summary>This is used in the <see cref="ICommandHelp"/> to send a list of command parameters to the client for explanatory help.</summary>
77
public interface ICommandOption
88
{
99
/// <summary>Gets or sets the name of the parameter.</summary>

DNN Platform/DotNetNuke.Abstractions/Prompt/IConsoleCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ public interface IConsoleCommand
1818
string ResultHtml { get; }
1919

2020
/// <summary>
21-
/// Initializes the command when invoked by the client. Note that you can opt to override this but you should
22-
/// call base.Initialize() to ensure all base values are loaded.
21+
/// Initializes the command when invoked by the client. Note that you can opt to override this, but you should
22+
/// call <c>base.Initialize()</c> to ensure all base values are loaded.
2323
/// </summary>
2424
/// <param name="args">Raw argument list passed by the client.</param>
2525
/// <param name="portalSettings">PortalSettings for the portal we're operating under or if PortalId is specified, that portal.</param>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information
4+
5+
namespace DotNetNuke.Abstractions.Prompt;
6+
7+
/// <summary>A field to be output which could contain plain text or HTML.</summary>
8+
public interface IConsoleOutput
9+
{
10+
/// <summary>Gets a value indicating whether <see cref="Output"/> is HTML or plain text.</summary>
11+
public bool IsHtml { get; }
12+
13+
/// <summary>Gets the output.</summary>
14+
public string Output { get; }
15+
}

DNN Platform/DotNetNuke.Abstractions/Prompt/IConsoleResultModel.cs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,30 @@ public interface IConsoleResultModel
1313
bool IsError { get; set; }
1414

1515
/// <summary>Gets or sets a value indicating whether output is HTML.</summary>
16-
/// <remarks>
17-
/// Let the client know if the output is HTML or not.
18-
/// </remarks>
16+
/// <remarks>Let the client know if the output is HTML or not.</remarks>
1917
bool IsHtml { get; set; }
2018

2119
/// <summary>Gets or sets a value indicating whether the prompt must reload.</summary>
22-
/// <remarks>
23-
/// Should the client reload after processing the command.
24-
/// </remarks>
20+
/// <remarks>Should the client reload after processing the command.</remarks>
2521
bool MustReload { get; set; }
2622

27-
/// <summary>Gets or sets if the response contains data to be formatted by the client.</summary>
23+
/// <summary>Gets or sets a list of data to be formatted by the client.</summary>
24+
/// <remarks>
25+
/// If the list contains a single item it will be displayed as a list of properties, otherwise the list will be displayed as a table.
26+
/// Each field will be rendered as plain text, unless it is wrapped in <see cref="IConsoleOutput"/>.
27+
/// </remarks>
2828
object Data { get; set; }
2929

3030
/// <summary>Gets or sets the field order.</summary>
31-
/// <remarks>
32-
/// Optionally tell the client in what order the fields should be displayed.
33-
/// </remarks>
31+
/// <remarks>Optionally tell the client in what order the fields should be displayed.</remarks>
3432
string[] FieldOrder { get; set; }
3533

3634
/// <summary>Gets or sets the <see cref="IPagingInfo"/>.</summary>
37-
/// <remarks>
38-
/// Information about paging of data. This allows the client to prompt the user
39-
/// to load the next page of data.
40-
/// </remarks>
35+
/// <remarks>Information about paging of data. This allows the client to prompt the user to load the next page of data.</remarks>
4136
IPagingInfo PagingInfo { get; set; }
4237

4338
/// <summary>Gets or sets the next page command.</summary>
44-
/// <remarks>
45-
/// Command to be used to display the next page of data. This is set in the
46-
/// WebAPI handler.
47-
/// </remarks>
39+
/// <remarks>Command to be used to display the next page of data. This is set in the WebAPI handler.</remarks>
4840
string NextPageCommand { get; set; }
4941

5042
/// <summary>Gets or sets the number of records retrieved (for this page).</summary>

DNN Platform/DotNetNuke.Abstractions/Prompt/IPagingInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ namespace DotNetNuke.Abstractions.Prompt
66
/// <summary>Used to page long lists of data to the client.</summary>
77
public interface IPagingInfo
88
{
9-
/// <summary>Gets or sets the current page nr.</summary>
9+
/// <summary>Gets or sets the current page number.</summary>
1010
int PageNo { get; set; }
1111

1212
/// <summary>Gets or sets the Page size.</summary>
1313
int PageSize { get; set; }
1414

15-
/// <summary>Gets or sets the total nr of pages.</summary>
15+
/// <summary>Gets or sets the total number of pages.</summary>
1616
int TotalPages { get; set; }
1717

18-
/// <summary>Gets or sets the total nr of records.</summary>
18+
/// <summary>Gets or sets the total number of records.</summary>
1919
int TotalRecords { get; set; }
2020
}
2121
}

DNN Platform/DotNetNuke.Web/Prompt/ListServices.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ namespace DotNetNuke.Web.Prompt
55
{
66
using System;
77
using System.Linq;
8-
using System.Net;
98

109
using DotNetNuke.Abstractions.Portals;
1110
using DotNetNuke.Abstractions.Prompt;
@@ -48,8 +47,8 @@ public override IConsoleResultModel Run()
4847
Service = this.GetTypeName(descriptor.ServiceType),
4948
Implementation = this.GetImplementationText(descriptor),
5049
})
51-
.OrderBy(desc => desc.Service)
52-
.ThenBy(desc => desc.Implementation)
50+
.OrderBy(desc => desc.Service.Output)
51+
.ThenBy(desc => desc.Implementation.Output)
5352
.ToList();
5453
return new ConsoleResultModel
5554
{
@@ -58,29 +57,29 @@ public override IConsoleResultModel Run()
5857
};
5958
}
6059

61-
private string GetImplementationText(ServiceDescriptor descriptor)
60+
private IConsoleOutput GetImplementationText(ServiceDescriptor descriptor)
6261
{
6362
if (descriptor.ImplementationInstance != null)
6463
{
65-
return this.LocalizeString("Prompt_ListServices_ImplementationInstance");
64+
return new HtmlOutput(this.LocalizeString("Prompt_ListServices_ImplementationInstance"));
6665
}
6766

6867
if (descriptor.ImplementationFactory != null)
6968
{
70-
return this.LocalizeString("Prompt_ListServices_ImplementationFactory");
69+
return new HtmlOutput(this.LocalizeString("Prompt_ListServices_ImplementationFactory"));
7170
}
7271

7372
return this.GetTypeName(descriptor.ImplementationType);
7473
}
7574

76-
private string GetTypeName(Type type)
75+
private IConsoleOutput GetTypeName(Type type)
7776
{
7877
if (type == null)
7978
{
80-
return this.LocalizeString("Prompt_ListServices_None");
79+
return new HtmlOutput(this.LocalizeString("Prompt_ListServices_None"));
8180
}
8281

83-
return WebUtility.HtmlEncode(type.FullName ?? type.Name);
82+
return new TextOutput(type.FullName ?? type.Name);
8483
}
8584
}
8685
}

DNN Platform/Library/DotNetNuke.Library.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,9 @@
326326
<Compile Include="Prompt\ConsoleCommand.cs" />
327327
<Compile Include="Prompt\Output\ConsoleErrorResultModel.cs" />
328328
<Compile Include="Prompt\Output\ConsoleResultModel.cs" />
329+
<Compile Include="Prompt\Output\HtmlOutput.cs" />
329330
<Compile Include="Prompt\Output\PagingInfo.cs" />
331+
<Compile Include="Prompt\Output\TextOutput.cs" />
330332
<Compile Include="Properties\AssemblyInfo.cs" />
331333
<Compile Include="Collections\CollectionExtensions.cs" />
332334
<Compile Include="Collections\IIndexable.cs" />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=prompt_005Cattributes/@EntryIndexedValue">True</s:Boolean>
3+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=prompt_005Ccommon/@EntryIndexedValue">True</s:Boolean>
4+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=prompt_005Coutput/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

DNN Platform/Library/Prompt/Attributes/ConsoleCommandAttribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace DotNetNuke.Prompt
55
{
66
using System;
77

8+
/// <summary>An attribute decorating a Prompt command.</summary>
89
[AttributeUsage(AttributeTargets.Class)]
910
public class ConsoleCommandAttribute : Attribute
1011
{

0 commit comments

Comments
 (0)