File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
src/ServiceManagement/Sql/Commands.SqlDatabase/Services/Server Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -381,10 +381,12 @@ public Database CreateNewDatabase(
381381 }
382382 }
383383
384+ SqlCollationCheck ( databaseCollation ) ;
385+
384386 commandText = string . Format (
385387 commandText ,
386388 SqlEscape ( databaseName ) ,
387- SqlEscape ( databaseCollation ) ,
389+ databaseCollation ,
388390 SqlEscape ( maxSizeVal ) ,
389391 SqlEscape ( databaseEdition . ToString ( ) ) ,
390392 SqlEscape ( serviceObjectiveName ) ) ;
@@ -405,6 +407,23 @@ public Database CreateNewDatabase(
405407 return GetDatabase ( databaseName ) ;
406408 }
407409
410+ private void SqlCollationCheck ( string databaseCollation )
411+ {
412+ bool isValid = databaseCollation . All ( ( c ) =>
413+ {
414+ if ( ! char . IsLetterOrDigit ( c ) && c != '_' )
415+ {
416+ return false ;
417+ }
418+ return true ;
419+ } ) ;
420+
421+ if ( ! isValid )
422+ {
423+ throw new ArgumentException ( "Invalid Collation" , "Collation" ) ;
424+ }
425+ }
426+
408427 /// <summary>
409428 /// Updates the property on the database with the name <paramref name="databaseName"/>.
410429 /// </summary>
You can’t perform that action at this time.
0 commit comments