@@ -11,9 +11,9 @@ public static class PatchExtractor
1111 {
1212 private static readonly Regex firstRegex = new Regex ( @":FIRST" , RegexOptions . IgnoreCase ) ;
1313 private static readonly Regex finalRegex = new Regex ( @":FINAL" , RegexOptions . IgnoreCase ) ;
14- private static readonly Regex beforeRegex = new Regex ( @":BEFORE\[([^\[\]]+)\]" , RegexOptions . IgnoreCase ) ;
15- private static readonly Regex forRegex = new Regex ( @":FOR\[([^\[\]]+)\]" , RegexOptions . IgnoreCase ) ;
16- private static readonly Regex afterRegex = new Regex ( @":AFTER\[([^\[\]]+)\]" , RegexOptions . IgnoreCase ) ;
14+ private static readonly Regex beforeRegex = new Regex ( @":BEFORE(?: \[([^\[\]]+)\])? " , RegexOptions . IgnoreCase ) ;
15+ private static readonly Regex forRegex = new Regex ( @":FOR(?: \[([^\[\]]+)\])? " , RegexOptions . IgnoreCase ) ;
16+ private static readonly Regex afterRegex = new Regex ( @":AFTER(?: \[([^\[\]]+)\])? " , RegexOptions . IgnoreCase ) ;
1717
1818 public static PatchList SortAndExtractPatches ( UrlDir databaseRoot , IEnumerable < string > modList , IPatchProgress progress )
1919 {
@@ -64,6 +64,21 @@ public static PatchList SortAndExtractPatches(UrlDir databaseRoot, IEnumerable<s
6464 progress . Error ( url , $ "Error - more than one pass specifier on a node: { url . SafeUrl ( ) } ") ;
6565 error = true ;
6666 }
67+ if ( beforeMatch . Success && ! beforeMatch . Groups [ 1 ] . Success )
68+ {
69+ progress . Error ( url , "Error - malformed :BEFORE patch specifier detected: " + url . SafeUrl ( ) ) ;
70+ error = true ;
71+ }
72+ if ( forMatch . Success && ! forMatch . Groups [ 1 ] . Success )
73+ {
74+ progress . Error ( url , "Error - malformed :FOR patch specifier detected: " + url . SafeUrl ( ) ) ;
75+ error = true ;
76+ }
77+ if ( afterMatch . Success && ! afterMatch . Groups [ 1 ] . Success )
78+ {
79+ progress . Error ( url , "Error - malformed :AFTER patch specifier detected: " + url . SafeUrl ( ) ) ;
80+ error = true ;
81+ }
6782 if ( error )
6883 {
6984 url . parent . configs . Remove ( url ) ;
0 commit comments