Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix encoding issues (#11008)
  • Loading branch information
sebastienros committed Jan 11, 2022
1 parent b015cc2 commit 4da927d
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 18 deletions.
Expand Up @@ -124,7 +124,7 @@ public async Task<IActionResult> Manage()
var authorized = await _authorizationService.AuthorizeAsync(User, CommonPermissions.EditContent, contentItem);
if (authorized)
{
dashboardCreatable.Add(new SelectListItem(new LocalizedString(ctd.DisplayName, ctd.DisplayName).Value, ctd.Name));
dashboardCreatable.Add(new SelectListItem(ctd.DisplayName, ctd.Name));
}
}

Expand Down
Expand Up @@ -32,7 +32,7 @@
<div class="dropdown-menu dropdown-menu-right scrollable" aria-labelledby="bulk-action-menu-button">
@foreach (var item in Model.Creatable)
{
<a class="dropdown-item add-list-widget btn-sm" href="@Url.RouteUrl(new { area = "OrchardCore.Contents", controller = "Admin", action = "Create", id = @item.Value, returnUrl = FullRequestPath })">@T[item.Text]</a>
<a class="dropdown-item add-list-widget btn-sm" href="@Url.RouteUrl(new { area = "OrchardCore.Contents", controller = "Admin", action = "Create", id = @item.Value, returnUrl = FullRequestPath })">@T[Html.Encode(item.Text)]</a>
}
</div>
</div>
Expand Down
Expand Up @@ -138,7 +138,7 @@ public class AdminController : Controller

if (await _authorizationService.AuthorizeAsync(context.User, CommonPermissions.EditContent, contentItem))
{
creatableList.Add(new SelectListItem(new LocalizedString(contentTypeDefinition.DisplayName, contentTypeDefinition.DisplayName).Value, contentTypeDefinition.Name));
creatableList.Add(new SelectListItem(contentTypeDefinition.DisplayName, contentTypeDefinition.Name));
}
}

Expand All @@ -157,7 +157,7 @@ public class AdminController : Controller

if (await _authorizationService.AuthorizeAsync(context.User, CommonPermissions.EditContent, contentItem))
{
creatableList.Add(new SelectListItem(new LocalizedString(contentTypeDefinition.DisplayName, contentTypeDefinition.DisplayName).Value, contentTypeDefinition.Name));
creatableList.Add(new SelectListItem(contentTypeDefinition.DisplayName, contentTypeDefinition.Name));
}
}
}
Expand Down
Expand Up @@ -10,7 +10,7 @@
var typeDisplayName = contentTypeDefinition?.DisplayName ?? contentItem.ContentType.CamelFriendly();
}

<zone Name="Title"><h1>@RenderTitleSegments(T["New {0}", Html.Raw(typeDisplayName)])</h1></zone>
<zone Name="Title"><h1>@RenderTitleSegments(T["New {0}", typeDisplayName])</h1></zone>

<form asp-action="Create" asp-route-returnUrl="@Context.Request.Query["ReturnUrl"]" method="post" enctype="multipart/form-data" class="no-multisubmit">
@Html.ValidationSummary()
Expand Down
Expand Up @@ -10,7 +10,7 @@
var typeDisplayName = contentTypeDefinition?.DisplayName ?? contentItem.ContentType.CamelFriendly();
}

<zone Name="Title"><h1>@RenderTitleSegments(T["Edit {0}", Html.Raw(typeDisplayName)])</h1></zone>
<zone Name="Title"><h1>@RenderTitleSegments(T["Edit {0}", typeDisplayName])</h1></zone>

<form asp-action="Edit" asp-route-contentitemid="@contentItem.ContentItemId" asp-route-returnUrl="@Context.Request.Query["ReturnUrl"]" method="post" enctype="multipart/form-data" class="no-multisubmit">
@Html.ValidationSummary()
Expand Down
Expand Up @@ -16,7 +16,7 @@
<div class="dropdown-menu dropdown-menu-right scrollable" aria-labelledby="bulk-action-menu-button">
@foreach (var item in Model.CreatableTypes)
{
<a class="dropdown-item" href="@Url.RouteUrl(new { area = "OrchardCore.Contents", controller = "Admin", action = "Create", id = @item.Value, returnUrl = FullRequestPath })">@T[item.Text]</a>
<a class="dropdown-item" href="@Url.RouteUrl(new { area = "OrchardCore.Contents", controller = "Admin", action = "Create", id = @item.Value, returnUrl = FullRequestPath })">@T[Html.Encode(item.Text)]</a>
}
</div>
</div>
Expand Down
Expand Up @@ -13,7 +13,7 @@
<script asp-name="codemirror-addon-display-autorefresh" at="Foot"></script>
<script asp-name="codemirror-mode-javascript" at="Foot"></script>

<zone Name="Title"><h1>@RenderTitleSegments(T["View As JSON {0}", Html.Raw(typeDisplayName)])</h1></zone>
<zone Name="Title"><h1>@RenderTitleSegments(T["View As JSON {0}", typeDisplayName])</h1></zone>

<form asp-action="Download" asp-route-contentItemId="@contentItem.ContentItemId" method="post" enctype="multipart/form-data" class="no-multisubmit">
<div class="form-group">
Expand Down
Expand Up @@ -29,7 +29,7 @@
Being an Admin Page my default path based route is automatically prefixed with the current 'AdminOptions.AdminUrlPrefix'.
</p>
<p>
@T[Model.Message]
@Model.Message
</p>
<p>
Date using the DateTimeShape: @await DisplayAsync(await New.DateTime(Utc: null, Format: T["MMMM dd, yyyy"].Value))
Expand Down
Expand Up @@ -22,7 +22,7 @@
<h2>Hello from @ViewContext.RouteData.Values["page"]</h2>

<p>
@T[Model.Message]
@Model.Message
</p>
<p>
Date using the DateTimeShape: @await DisplayAsync(await New.DateTime(Utc: null, Format: T["MMMM dd, yyyy"].Value))
Expand Down
Expand Up @@ -31,7 +31,7 @@
Being an Admin Page my default path based route is automatically prefixed with the current 'AdminOptions.AdminUrlPrefix'.
</p>
<p>
@T[Model.Message]
@Model.Message
</p>
<p>
Date using the DateTimeShape: @await DisplayAsync(await New.DateTime(Utc: null, Format: T["MMMM dd, yyyy"].Value))
Expand Down
Expand Up @@ -23,7 +23,7 @@

<div class="btn-group btn-group-sm" role="group">
<button type="button" class="btn btn-secondary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@T[Model.Size + "%"]
@T[Html.Encode(Model.Size + "%")] @* Allows for custom string reprentations like half, quarter, ...*@
</button>
<div class="dropdown-menu btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary dropdown-item @(Model.Size == 25 ? "active" : null)">
Expand Down
Expand Up @@ -51,7 +51,7 @@
<ul class="list-group zones">
@foreach (var contentItemSummary in Model.Widgets[zone])
{
await contentItemSummary.Tags.AddAsync(Html.Raw("<span class=\"badge ta-badge font-weight-normal\"><i class=\"fa fa-bookmark-o text-info\" aria-hidden=\"true\"></i> " + contentItemSummary.ContentItem.Content.LayerMetadata.Layer + "</span>"));
await contentItemSummary.Tags.AddAsync(Html.Raw("<span class=\"badge ta-badge font-weight-normal\"><i class=\"fa fa-bookmark-o text-info\" aria-hidden=\"true\"></i> " + Html.Encode(contentItemSummary.ContentItem.Content.LayerMetadata.Layer) + "</span>"));
maxPosition = Math.Max(maxPosition, (double)contentItemSummary.ContentItem.Content.LayerMetadata.Position);

<text>
Expand Down
Expand Up @@ -14,7 +14,16 @@
<select asp-for="UsersCanRegister" class="form-control">
@foreach (UserRegistrationType option in Enum.GetValues(typeof(UserRegistrationType)))
{
<option value="@option" selected="@(Model.UsersCanRegister == option)">@T[option.ToString()]</option>
<option value="@option" selected="@(Model.UsersCanRegister == option)">
@{
switch (option)
{
case UserRegistrationType.NoRegistration: @T["NoRegistration"]; break;
case UserRegistrationType.AllowRegistration: @T["AllowRegistration"]; break;
case UserRegistrationType.AllowOnlyExternalUsers: @T["AllowOnlyExternalUsers"]; break;
}
}
</option>
}
</select>
<span asp-validation-for="UsersCanRegister"></span>
Expand Down
Expand Up @@ -8,12 +8,12 @@
@foreach (var action in actions)
{
<div class="btn-group" role="group">
<button class="btn btn-warning" type="submit" name="submit.Save" value="user-task.@action">@T[action] @T["and Save"]</button>
<button class="btn btn-warning" type="submit" name="submit.Save" value="user-task.@action">@T[Html.Encode(action)] @T["and Save"]</button>
<button type="button" class="btn btn-warning dropdown-toggle dropdown-toggle-split" data-reference="parent" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="sr-only">@T["Toggle Dropdown"]</span>
</button>
<div class="dropdown-menu" aria-labelledby="userActionsButtonGroup">
<button type="submit" name="submit.Publish" class="dropdown-item" value="user-task.@action">@T[action] @T["and Publish"]</button>
<button type="submit" name="submit.Publish" class="dropdown-item" value="user-task.@action">@T[Html.Encode(action)] @T["and Publish"]</button>
</div>
</div>
}
Expand All @@ -27,8 +27,8 @@ else
<div class="dropdown-menu" aria-labelledby="userActionsButtonGroup">
@foreach (var action in actions)
{
<button type="submit" name="submit.Save" class="dropdown-item" value="user-task.@action">@T[action] @T["and Save"]</button>
<button type="submit" name="submit.Publish" class="dropdown-item" value="user-task.@action">@T[action] @T["and Publish"]</button>
<button type="submit" name="submit.Save" class="dropdown-item" value="user-task.@action">@T[Html.Encode(action)] @T["and Save"]</button>
<button type="submit" name="submit.Publish" class="dropdown-item" value="user-task.@action">@T[Html.Encode(action)] @T["and Publish"]</button>
}
</div>
</div>
Expand Down

0 comments on commit 4da927d

Please sign in to comment.