Server side validation of illegal chars in folder names
This commit is contained in:
committed by
Sebastiaan Janssen
parent
55aec0bf07
commit
1002113e7d
@@ -75,11 +75,14 @@ namespace Umbraco.Web.Editors
|
||||
/// <param name="name">The name of the container/folder</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public CodeFileDisplay PostCreateContainer(string type, string parentId, string name)
|
||||
public HttpResponseMessage PostCreateContainer(string type, string parentId, string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(type)) throw new ArgumentException("Value cannot be null or whitespace.", "type");
|
||||
if (string.IsNullOrWhiteSpace(parentId)) throw new ArgumentException("Value cannot be null or whitespace.", "parentId");
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value cannot be null or whitespace.", "name");
|
||||
if (name.ContainsAny(Path.GetInvalidPathChars())) {
|
||||
return Request.CreateNotificationValidationErrorResponse("The folder name cannot contain illegal characters.");
|
||||
}
|
||||
|
||||
// if the parentId is root (-1) then we just need an empty string as we are
|
||||
// creating the path below and we don't want -1 in the path
|
||||
@@ -118,11 +121,11 @@ namespace Umbraco.Web.Editors
|
||||
|
||||
}
|
||||
|
||||
return new CodeFileDisplay
|
||||
return Request.CreateResponse(HttpStatusCode.OK, new CodeFileDisplay
|
||||
{
|
||||
VirtualPath = virtualPath,
|
||||
Path = Url.GetTreePathFromFilePath(virtualPath)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user