Implements 26845 and 26846 - updates to Alias validation
[TFS Changeset #65688]
This commit is contained in:
@@ -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";
|
||||
|
||||
/// <summary>
|
||||
/// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,4 +94,5 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
duplicatePropertyNameAsSafeAlias('ctl00_body_ContentTypeControlNew1_GenericPropertyNew_control_tbName', 'ctl00_body_ContentTypeControlNew1_GenericPropertyNew_control_tbAlias');
|
||||
checkAlias('ctl00_body_ContentTypeControlNew1_txtAlias');
|
||||
</script>
|
||||
@@ -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));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user