Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions 3 BlogEngine/BlogEngine.Core/Data/UsersRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public BlogUser Add(BlogUser user)
if (!Security.IsAuthorizedTo(Rights.CreateNewUsers))
throw new UnauthorizedAccessException();

if (user.UserName.Contains("/") || user.UserName.Contains(@"\"))
throw new ApplicationException("Error adding new user; Invalid character detected in UserName");

// create user
var usr = Membership.CreateUser(user.UserName, user.Password, user.Email);
if (usr == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private static string BlogAbsolutePath(string VirtualPath)
private static string RelativeFilePath(string VirtualPath)
{
VirtualPath = VirtualPath.Replace("//","/").Trim();
if (VirtualPath.ToLower().Contains(FileContainerRoot.ToLower()))
if (VirtualPath.ToLower().Contains(FileContainerRoot.ToLower()+"/") || VirtualPath.ToLower() == FileContainerRoot.ToLower())
return VirtualPath;

// ex: Oct 18 2012, added this to handle the case on the File Manager where if
Expand Down
4 changes: 3 additions & 1 deletion 4 BlogEngine/BlogEngine.NET/AppCode/Api/UploadController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public HttpResponseMessage Post(string action, string dirPath = "")
dir = BlogService.GetDirectory("/avatars");
var dot = fileName.LastIndexOf(".");
var ext = dot > 0 ? fileName.Substring(dot) : "";
if (User.Identity.Name.Contains("/") || User.Identity.Name.Contains(@"\"))
throw new ApplicationException("Invalid character detected in UserName");
var profileFileName = User.Identity.Name + ext;

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

#endregion
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.