diff --git a/src/Orchard.Web/Modules/Orchard.Warmup/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Warmup/Controllers/AdminController.cs index 76df64708..05654cd09 100644 --- a/src/Orchard.Web/Modules/Orchard.Warmup/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Warmup/Controllers/AdminController.cs @@ -51,7 +51,14 @@ namespace Orchard.Warmup.Controllers { var warmupPart = Services.WorkContext.CurrentSite.As(); if(TryUpdateModel(warmupPart)) { - Services.Notifier.Information(T("Warmup updated successfully.")); + using (var urlReader = new StringReader(warmupPart.Urls)) { + string relativeUrl; + while (null != (relativeUrl = urlReader.ReadLine())) { + if(!Uri.IsWellFormedUriString(relativeUrl, UriKind.Relative) || !(relativeUrl.StartsWith("/"))) { + AddModelError("Urls", T("{0} is an invalid warmup url.", relativeUrl)); + } + } + } } if (warmupPart.Scheduled) { @@ -60,6 +67,7 @@ namespace Orchard.Warmup.Controllers { } } + Services.Notifier.Information(T("Warmup updated successfully.")); return View(warmupPart); } @@ -76,83 +84,6 @@ namespace Orchard.Warmup.Controllers { return result; } - - [FormValueRequired("submit.Extract")] - [HttpPost, ActionName("Index")] - public ActionResult IndexPostExtract() { - var baseUrl = Services.WorkContext.CurrentSite.BaseUrl; - baseUrl = VirtualPathUtility.AppendTrailingSlash(baseUrl); - - var part = Services.WorkContext.CurrentSite.As(); - - if (String.IsNullOrWhiteSpace(baseUrl) || String.IsNullOrWhiteSpace(part.Urls)) { - return RedirectToAction("Index"); - } - - var regex = new Regex(@"]*href=""(?[^""]*\.css)""|]*src=""(?[^""]*\.js)""", RegexOptions.IgnoreCase); - var resources = new List(); - - // add the already registered urls to remove duplicates - using (var urlReader = new StringReader(part.Urls)) { - string relativeUrl; - while (null != (relativeUrl = urlReader.ReadLine())) { - if (String.IsNullOrWhiteSpace(relativeUrl)) { - continue; - } - - relativeUrl = relativeUrl.Trim(); - resources.Add(relativeUrl); - - try { - var contentUrl = VirtualPathUtility.RemoveTrailingSlash(baseUrl) + relativeUrl; - var filename = WarmupUtility.EncodeUrl(contentUrl.TrimEnd('/')); - var path = _appDataFolder.Combine("Warmup", filename); - - if(!_appDataFolder.FileExists(path)) { - continue; - } - - var content = _appDataFolder.ReadFile(path); - - // process only html files - if (!content.Contains(" x.ToLowerInvariant()).Select(x => x.First()).ToArray(); - part.Urls = String.Join(System.Environment.NewLine, uniqueResources); - - return RedirectToAction("Index"); - } - bool IUpdateModel.TryUpdateModel(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { return TryUpdateModel(model, prefix, includeProperties, excludeProperties); } diff --git a/src/Orchard.Web/Modules/Orchard.Warmup/Views/Admin/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Warmup/Views/Admin/Index.cshtml index bc77e781c..a0d0fd5bd 100644 --- a/src/Orchard.Web/Modules/Orchard.Warmup/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Warmup/Views/Admin/Index.cshtml @@ -33,6 +33,5 @@
-
}