File tree Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ class PathValidator extends BaseValidator<String> {
22
22
///
23
23
/// Examples: /path/to/file, C:/Users/Name/Documents
24
24
/// {@endtemplate}
25
- static final RegExp _filePath = RegExp (r'^[a-zA-Z0-9_\-\/]+$' );
25
+ static final RegExp _filePath =
26
+ RegExp (r'^((\/|\\|[a-zA-Z]:\/)?([^<>:"|?*]+(\/|\\)?)+)$' );
26
27
27
28
@override
28
29
String get translatedErrorText =>
Original file line number Diff line number Diff line change @@ -194,18 +194,18 @@ class UrlValidator extends BaseValidator<String> {
194
194
}
195
195
}
196
196
197
+ final String partPattern = allowUnderscores
198
+ ? r'^[a-z\u00a1-\uffff0-9-_]+$'
199
+ : r'^[a-z\u00a1-\uffff0-9-]+$' ;
200
+
197
201
for (final String part in parts) {
198
- if (allowUnderscores) {
199
- if (part.contains ('__' )) {
200
- return false ;
201
- }
202
- }
203
- if (! RegExp (r'^[a-z\\u00a1-\\uffff0-9-]+$' ).hasMatch (part)) {
202
+ if (! RegExp (partPattern).hasMatch (part)) {
204
203
return false ;
205
204
}
206
205
if (part[0 ] == '-' ||
207
206
part[part.length - 1 ] == '-' ||
208
- part.contains ('---' )) {
207
+ part.contains ('---' ) ||
208
+ (allowUnderscores && part.contains ('__' ))) {
209
209
return false ;
210
210
}
211
211
}
Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ void main() {
34
34
'folder/subfolder/file<name>.txt' ,
35
35
'folder?name/subfolder/file.txt' ,
36
36
'folder/subfolder/file:name.txt' ,
37
- r'folder\subfolder\file.txt' ,
38
37
];
39
38
40
39
// Act & Assert
@@ -55,7 +54,6 @@ void main() {
55
54
'folder/subfolder/file<name>.txt' ,
56
55
'folder?name/subfolder/file.txt' ,
57
56
'folder/subfolder/file:name.txt' ,
58
- r'folder\subfolder\file.txt' ,
59
57
];
60
58
61
59
// Act & Assert
You can’t perform that action at this time.
0 commit comments