Skip to content

Commit 61daddf

Browse files
committed
1 parent 7f92756 commit 61daddf

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

BlogEngine/BlogEngine.Core/Data/UsersRepository.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ public BlogUser Add(BlogUser user)
9898
if (!Security.IsAuthorizedTo(Rights.CreateNewUsers))
9999
throw new UnauthorizedAccessException();
100100

101+
if (user.UserName.Contains("/") || user.UserName.Contains(@"\"))
102+
throw new ApplicationException("Error adding new user; Invalid character detected in UserName");
103+
101104
// create user
102105
var usr = Membership.CreateUser(user.UserName, user.Password, user.Email);
103106
if (usr == null)

BlogEngine/BlogEngine.NET/AppCode/Api/UploadController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public HttpResponseMessage Post(string action, string dirPath = "")
6464
dir = BlogService.GetDirectory("/avatars");
6565
var dot = fileName.LastIndexOf(".");
6666
var ext = dot > 0 ? fileName.Substring(dot) : "";
67+
if (User.Identity.Name.Contains("/") || User.Identity.Name.Contains(@"\"))
68+
throw new ApplicationException("Invalid character detected in UserName");
6769
var profileFileName = User.Identity.Name + ext;
6870

6971
var imgPath = HttpContext.Current.Server.MapPath(dir.FullPath + "/" + profileFileName);
@@ -157,4 +159,4 @@ private void UploadVideo(string virtualFolder, HttpPostedFile file, string fileN
157159
}
158160

159161
#endregion
160-
}
162+
}

0 commit comments

Comments
 (0)