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,
|
||||||
@@ -98,7 +96,7 @@ namespace Umbraco.Web.WebServices
|
|||||||
oldname = oldname.TrimStart(pathPrefix);
|
oldname = oldname.TrimStart(pathPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentView = oldname.IsNullOrWhiteSpace()
|
var currentView = oldname.IsNullOrWhiteSpace()
|
||||||
? get(svce, filename)
|
? get(svce, filename)
|
||||||
: get(svce, oldname);
|
: get(svce, oldname);
|
||||||
|
|
||||||
@@ -108,7 +106,7 @@ namespace Umbraco.Web.WebServices
|
|||||||
currentView.Path = filename;
|
currentView.Path = filename;
|
||||||
currentView.Content = contents;
|
currentView.Content = contents;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Attempt<IPartialView> attempt;
|
Attempt<IPartialView> attempt;
|
||||||
@@ -166,7 +164,7 @@ namespace Umbraco.Web.WebServices
|
|||||||
if (Math.Max(t.MasterTemplate, 0) != Math.Max(masterTemplateId, 0))
|
if (Math.Max(t.MasterTemplate, 0) != Math.Max(masterTemplateId, 0))
|
||||||
{
|
{
|
||||||
t.MasterTemplate = Math.Max(masterTemplateId, 0);
|
t.MasterTemplate = Math.Max(masterTemplateId, 0);
|
||||||
pathChanged = true;
|
pathChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException ex)
|
catch (ArgumentException ex)
|
||||||
@@ -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);
|
||||||
@@ -223,7 +219,7 @@ namespace Umbraco.Web.WebServices
|
|||||||
if (svce.ValidateScript(script) == false)
|
if (svce.ValidateScript(script) == false)
|
||||||
return Failed(ui.Text("speechBubbles", "scriptErrorText"), ui.Text("speechBubbles", "scriptErrorHeader"),
|
return Failed(ui.Text("speechBubbles", "scriptErrorText"), ui.Text("speechBubbles", "scriptErrorHeader"),
|
||||||
new FileSecurityException("File '" + filename + "' is not a valid script file."));
|
new FileSecurityException("File '" + filename + "' is not a valid script file."));
|
||||||
|
|
||||||
svce.SaveScript(script);
|
svce.SaveScript(script);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -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>
|
||||||
|
|||||||
+2
-2
@@ -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)
|
||||||
{
|
{
|
||||||
@@ -154,4 +154,4 @@ namespace umbraco.cms.presentation.settings.stylesheet
|
|||||||
protected global::umbraco.uicontrols.CodeArea editorSource;
|
protected global::umbraco.uicontrols.CodeArea editorSource;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user