File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,12 @@ static IEnumerable<string> FindAssemblyCandidates(string name)
200
200
}
201
201
else
202
202
{
203
+ int invalidCharIndex = head . IndexOfAny ( Path . GetInvalidPathChars ( ) ) ;
204
+ if ( invalidCharIndex >= 0 )
205
+ {
206
+ Exceptions . warn ( $ "Path entry '{ head } ' has invalid char at position { invalidCharIndex } ", Exceptions . ValueError ) ;
207
+ continue ;
208
+ }
203
209
path = Path . Combine ( head , name ) ;
204
210
}
205
211
Original file line number Diff line number Diff line change @@ -344,6 +344,20 @@ def test_clr_add_reference():
344
344
with pytest .raises (FileNotFoundException ):
345
345
AddReference ("somethingtotallysilly" )
346
346
347
+
348
+ def test_clr_add_reference_bad_path ():
349
+ import sys
350
+ from clr import AddReference
351
+ from System .IO import FileNotFoundException
352
+ bad_path = "hello\0 world"
353
+ sys .path .append (bad_path )
354
+ try :
355
+ with pytest .raises (FileNotFoundException ):
356
+ AddReference ("test_clr_add_reference_bad_path" )
357
+ finally :
358
+ sys .path .remove (bad_path )
359
+
360
+
347
361
def test_clr_get_clr_type ():
348
362
"""Test clr.GetClrType()."""
349
363
from clr import GetClrType
You can’t perform that action at this time.
0 commit comments