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(
381
381
}
382
382
}
383
383
384
+ SqlCollationCheck ( databaseCollation ) ;
385
+
384
386
commandText = string . Format (
385
387
commandText ,
386
388
SqlEscape ( databaseName ) ,
387
- SqlEscape ( databaseCollation ) ,
389
+ databaseCollation ,
388
390
SqlEscape ( maxSizeVal ) ,
389
391
SqlEscape ( databaseEdition . ToString ( ) ) ,
390
392
SqlEscape ( serviceObjectiveName ) ) ;
@@ -405,6 +407,23 @@ public Database CreateNewDatabase(
405
407
return GetDatabase ( databaseName ) ;
406
408
}
407
409
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
+
408
427
/// <summary>
409
428
/// Updates the property on the database with the name <paramref name="databaseName"/>.
410
429
/// </summary>
You can’t perform that action at this time.
0 commit comments