#19362: Fixing another regex and removing starts with and ends with dots.

Work Item: 19362

--HG--
branch : 1.x
This commit is contained in:
Nicholas Mayne
2013-06-08 09:00:40 +01:00
parent d807d2bb80
commit 2288322a41
2 changed files with 2 additions and 6 deletions

View File

@@ -94,11 +94,7 @@ namespace Orchard.Autoroute.Drivers {
}
if (!_autorouteService.IsPathValid(part.DisplayAlias)) {
var path = (part.DisplayAlias ?? String.Empty);
if (path.StartsWith(".") || path.EndsWith("."))
updater.AddModelError("CurrentUrl", T("The \".\" can't be used at either end of the permalink."));
else
updater.AddModelError("CurrentUrl", T("Please do not use any of the following characters in your permalink: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\", \"\\\", \"|\", \"%\". No spaces are allowed (please use dashes or underscores instead)."));
updater.AddModelError("CurrentUrl", T("Please do not use any of the following characters in your permalink: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\", \"\\\", \"|\", \"%\", \".\". No spaces are allowed (please use dashes or underscores instead)."));
}
// if CurrentUrl is set, the handler won't try to create an alias for it

View File

@@ -166,7 +166,7 @@ namespace Orchard.Autoroute.Services {
}
public bool IsPathValid(string slug) {
return String.IsNullOrWhiteSpace(slug) || Regex.IsMatch(slug, @"^[^:?#\[\]@!$&'()*+,;=\s\""\<\>\\\|%]+$") && !(slug.StartsWith(".") || slug.EndsWith("."));
return String.IsNullOrWhiteSpace(slug) || Regex.IsMatch(slug, @"^[^:?#\[\]@!$&'()*+,.;=\s\""\<\>\\\|%]+$");
}
public bool ProcessPath(AutoroutePart part) {