Compare commits
5 Commits
netcore/dev
...
3123
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d5ce72178 | |||
| 871da7036f | |||
| 9828e36e72 | |||
| aa703caaf0 | |||
| 362f9db6f8 |
@@ -39,13 +39,13 @@ namespace Umbraco.Web.WebServices
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public JsonResult SavePartialViewMacro(string filename, string oldName, string contents)
|
public JsonResult SavePartialViewMacro(string filename, string oldName, string contents)
|
||||||
{
|
{
|
||||||
var svce = (FileService) Services.FileService;
|
var svce = (FileService)Services.FileService;
|
||||||
|
|
||||||
return SavePartialView(svce,
|
return SavePartialView(svce,
|
||||||
filename, oldName, contents,
|
filename, oldName, contents,
|
||||||
"MacroPartials/",
|
"MacroPartials/",
|
||||||
(s, n) => s.GetPartialViewMacro(n),
|
(s, n) => s.GetPartialViewMacro(n),
|
||||||
(s, v) => s.ValidatePartialViewMacro((PartialView) v),
|
(s, v) => s.ValidatePartialViewMacro((PartialView)v),
|
||||||
(s, v) => s.SavePartialViewMacro(v));
|
(s, v) => s.SavePartialViewMacro(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,13 +59,13 @@ namespace Umbraco.Web.WebServices
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
public JsonResult SavePartialView(string filename, string oldName, string contents)
|
public JsonResult SavePartialView(string filename, string oldName, string contents)
|
||||||
{
|
{
|
||||||
var svce = (FileService) Services.FileService;
|
var svce = (FileService)Services.FileService;
|
||||||
|
|
||||||
return SavePartialView(svce,
|
return SavePartialView(svce,
|
||||||
filename, oldName, contents,
|
filename, oldName, contents,
|
||||||
"Partials/",
|
"Partials/",
|
||||||
(s, n) => s.GetPartialView(n),
|
(s, n) => s.GetPartialView(n),
|
||||||
(s, v) => s.ValidatePartialView((PartialView) v),
|
(s, v) => s.ValidatePartialView((PartialView)v),
|
||||||
(s, v) => s.SavePartialView(v));
|
(s, v) => s.SavePartialView(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,9 +77,7 @@ namespace Umbraco.Web.WebServices
|
|||||||
Func<IFileService, IPartialView, Attempt<IPartialView>> save)
|
Func<IFileService, IPartialView, Attempt<IPartialView>> save)
|
||||||
{
|
{
|
||||||
// sanitize input - partial view names have an extension
|
// sanitize input - partial view names have an extension
|
||||||
filename = filename
|
filename = CleanFilename(filename);
|
||||||
.Replace('\\', '/')
|
|
||||||
.TrimStart('/');
|
|
||||||
|
|
||||||
// sharing the editor with partial views & partial view macros,
|
// sharing the editor with partial views & partial view macros,
|
||||||
// using path prefix to differenciate,
|
// using path prefix to differenciate,
|
||||||
@@ -206,11 +204,9 @@ namespace Umbraco.Web.WebServices
|
|||||||
public JsonResult SaveScript(string filename, string oldName, string contents)
|
public JsonResult SaveScript(string filename, string oldName, string contents)
|
||||||
{
|
{
|
||||||
// sanitize input - script names have an extension
|
// sanitize input - script names have an extension
|
||||||
filename = filename
|
filename = CleanFilename(filename);
|
||||||
.Replace('\\', '/')
|
|
||||||
.TrimStart('/');
|
|
||||||
|
|
||||||
var svce = (FileService) Services.FileService;
|
var svce = (FileService)Services.FileService;
|
||||||
var script = svce.GetScriptByName(oldName);
|
var script = svce.GetScriptByName(oldName);
|
||||||
if (script == null)
|
if (script == null)
|
||||||
script = new Script(filename);
|
script = new Script(filename);
|
||||||
@@ -245,12 +241,18 @@ namespace Umbraco.Web.WebServices
|
|||||||
public JsonResult SaveStylesheet(string filename, string oldName, string contents)
|
public JsonResult SaveStylesheet(string filename, string oldName, string contents)
|
||||||
{
|
{
|
||||||
// sanitize input - stylesheet names have no extension
|
// sanitize input - stylesheet names have no extension
|
||||||
filename = filename
|
var svce = (FileService)Services.FileService;
|
||||||
.Replace('\\', '/')
|
|
||||||
.TrimStart('/')
|
filename = CleanFilename(filename);
|
||||||
.EnsureEndsWith(".css");
|
oldName = CleanFilename(oldName);
|
||||||
|
|
||||||
|
if (filename != oldName)
|
||||||
|
{
|
||||||
|
var stylesheetExists = svce.GetStylesheetByName(filename);
|
||||||
|
if (stylesheetExists != null)
|
||||||
|
return Failed(ui.Text("speechBubbles", "cssErrorText"), "A file named '" + filename + ".css' already exists.");
|
||||||
|
}
|
||||||
|
|
||||||
var svce = (FileService) Services.FileService;
|
|
||||||
var stylesheet = svce.GetStylesheetByName(oldName);
|
var stylesheet = svce.GetStylesheetByName(oldName);
|
||||||
if (stylesheet == null)
|
if (stylesheet == null)
|
||||||
stylesheet = new Stylesheet(filename);
|
stylesheet = new Stylesheet(filename);
|
||||||
@@ -281,6 +283,14 @@ namespace Umbraco.Web.WebServices
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string CleanFilename(string filename)
|
||||||
|
{
|
||||||
|
return filename
|
||||||
|
.Replace('\\', '/')
|
||||||
|
.TrimStart('/')
|
||||||
|
.EnsureEndsWith(".css");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a successful message
|
/// Returns a successful message
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ namespace umbraco.cms.presentation.settings.stylesheet
|
|||||||
TreeSyncPath = DeepLink.GetTreePathFromFilePath(filename).TrimEnd(".css");
|
TreeSyncPath = DeepLink.GetTreePathFromFilePath(filename).TrimEnd(".css");
|
||||||
|
|
||||||
// name derives from path, without the .css extension, clean for xss
|
// name derives from path, without the .css extension, clean for xss
|
||||||
NameTxt.Text = stylesheet.Path.TrimEnd(".css").CleanForXss('\\', '/');
|
NameTxt.Text = stylesheet.Path.TrimEnd(".css").CleanForXss('\\', '/').Replace("\\", "/");
|
||||||
|
|
||||||
if (IsPostBack == false)
|
if (IsPostBack == false)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user