Skip to content

Commit 7ee5ff0

Browse files
committed
Move call to AddPackageOwner to requrie an object so we can allow html characters for message only.
1 parent 00fc0f0 commit 7ee5ff0

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/NuGetGallery/Controllers/JsonApiController.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ public virtual ActionResult GetPackageOwners(string id)
103103

104104
[HttpPost]
105105
[ValidateAntiForgeryToken]
106-
public async Task<JsonResult> AddPackageOwner(string id, string username, string message)
106+
public async Task<JsonResult> AddPackageOwner(AddPackageOwnerViewModel addOwnerData)
107107
{
108+
string id = addOwnerData.Id;
109+
string username = addOwnerData.Username;
110+
string message = addOwnerData.Message;
111+
108112
if (Regex.IsMatch(username, GalleryConstants.EmailValidationRegex, RegexOptions.None, GalleryConstants.EmailValidationRegexTimeout))
109113
{
110114
return Json(new { success = false, message = Strings.AddOwner_NameIsEmail }, JsonRequestBehavior.AllowGet);

src/NuGetGallery/NuGetGallery.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@
748748
<Compile Include="Telemetry\UserPackageDeleteOutcome.cs" />
749749
<Compile Include="UrlHelperExtensions.cs" />
750750
<Compile Include="ViewModels\AddOrganizationViewModel.cs" />
751+
<Compile Include="ViewModels\AddPackageOwnerViewModel.cs" />
751752
<Compile Include="ViewModels\CompositeLicenseExpressionSegmentViewModel.cs" />
752753
<Compile Include="ViewModels\DeleteOrganizationViewModel.cs" />
753754
<Compile Include="ViewModels\DeleteUserViewModel.cs" />
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System.Web.Mvc;
5+
6+
namespace NuGetGallery
7+
{
8+
public class AddPackageOwnerViewModel
9+
{
10+
public string Id { get; set; }
11+
public string Username { get; set; }
12+
13+
[AllowHtml]
14+
public string Message { get; set; }
15+
}
16+
}

0 commit comments

Comments
 (0)