diff --git a/umbraco/cms/helpers/Casing.cs b/umbraco/cms/helpers/Casing.cs index 5e3dfac8cc..05b9044504 100644 --- a/umbraco/cms/helpers/Casing.cs +++ b/umbraco/cms/helpers/Casing.cs @@ -7,7 +7,8 @@ namespace umbraco.cms.helpers { public class Casing { - public const string VALID_ALIAS_CHARACTERS = "_-abcdefghijklmnopqrstuvwxyz"; + public const string VALID_ALIAS_CHARACTERS = "_-abcdefghijklmnopqrstuvwxyz1234567890"; + public const string INVALID_FIRST_CHARACTERS = "01234567890"; /// /// A helper method to ensure that an Alias string doesn't contains any illegal characters @@ -26,10 +27,17 @@ namespace umbraco.cms.helpers if (VALID_ALIAS_CHARACTERS.Contains(currentChar.ToLower())) { // check for camel (if previous character is a space, we'll upper case the current one - if (i < aliasLength - 1 && i > 0 && alias.Substring(i - 1, 1) == " ") - currentChar = currentChar.ToUpper(); + if (i == 0 && INVALID_FIRST_CHARACTERS.Contains(currentChar.ToLower())) + { + currentChar = ""; + } + else + { + if (i < aliasLength - 1 && i > 0 && alias.Substring(i - 1, 1) == " ") + currentChar = currentChar.ToUpper(); - safeString.Append(currentChar); + safeString.Append(currentChar); + } } } diff --git a/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx b/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx index d880f1504c..1b5f3a5d87 100644 --- a/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx +++ b/umbraco/presentation/umbraco/controls/ContentTypeControlNew.ascx @@ -94,4 +94,5 @@ \ No newline at end of file diff --git a/umbraco/presentation/umbraco/js/UmbracoCasingRules.aspx.cs b/umbraco/presentation/umbraco/js/UmbracoCasingRules.aspx.cs index 416309f982..304fd73eb1 100644 --- a/umbraco/presentation/umbraco/js/UmbracoCasingRules.aspx.cs +++ b/umbraco/presentation/umbraco/js/UmbracoCasingRules.aspx.cs @@ -16,7 +16,8 @@ namespace umbraco.presentation.js Response.Write(String.Format(@" var UMBRACO_FORCE_SAFE_ALIAS = {0}; var UMBRACO_FORCE_SAFE_ALIAS_VALIDCHARS = '{1}'; -", UmbracoSettings.ForceSafeAliases.ToString().ToLower(), Casing.VALID_ALIAS_CHARACTERS)); +var UMBRACO_FORCE_SAFE_ALIAS_INVALID_FIRST_CHARS = '{2}'; +", UmbracoSettings.ForceSafeAliases.ToString().ToLower(), Casing.VALID_ALIAS_CHARACTERS, Casing.INVALID_FIRST_CHARACTERS)); } diff --git a/umbraco/presentation/umbraco_client/GenericProperty/genericProperty.js b/umbraco/presentation/umbraco_client/GenericProperty/genericProperty.js index 4dde1a590a..f54b120e30 100644 --- a/umbraco/presentation/umbraco_client/GenericProperty/genericProperty.js +++ b/umbraco/presentation/umbraco_client/GenericProperty/genericProperty.js @@ -41,10 +41,14 @@ function safeAlias(alias) { currentChar = alias.substring(i, i + 1); if (UMBRACO_FORCE_SAFE_ALIAS_VALIDCHARS.indexOf(currentChar.toLowerCase()) > -1) { // check for camel (if previous character is a space, we'll upper case the current one - if (i < aliasLength - 1 && i > 0 && alias.substring(i - 1, i) == ' ') - currentChar = currentChar.toUpperCase(); + if (i == 0 && UMBRACO_FORCE_SAFE_ALIAS_INVALID_FIRST_CHARS.indexOf(currentChar.toLowerCase()) > 0) { + currentChar = ''; + } else { + if (i < aliasLength - 1 && i > 0 && alias.substring(i - 1, i) == ' ') + currentChar = currentChar.toUpperCase(); - safeAlias += currentChar; + safeAlias += currentChar; + } } }