Skip to content

Commit

Permalink
Adding some additional checks for collation name.
Browse files Browse the repository at this point in the history
  • Loading branch information
akromm-zz committed Dec 8, 2014
1 parent 6f3380c commit 6b56718
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,12 @@ public Database CreateNewDatabase(
}
}

SqlCollationCheck(databaseCollation);

commandText = string.Format(
commandText,
SqlEscape(databaseName),
SqlEscape(databaseCollation),
databaseCollation,
SqlEscape(maxSizeVal),
SqlEscape(databaseEdition.ToString()),
SqlEscape(serviceObjectiveName));
Expand All @@ -405,6 +407,23 @@ public Database CreateNewDatabase(
return GetDatabase(databaseName);
}

private void SqlCollationCheck(string databaseCollation)
{
bool isValid = databaseCollation.All( (c) =>
{
if(!char.IsLetterOrDigit(c) && c != '_')
{
return false;
}
return true;
});

if(!isValid)
{
throw new ArgumentException("Invalid Collation", "Collation");
}
}

/// <summary>
/// Updates the property on the database with the name <paramref name="databaseName"/>.
/// </summary>
Expand Down

0 comments on commit 6b56718

Please sign in to comment.