Check if a reparsepoint is a symlink before trying to get target (#9895)

This commit is contained in:
Steve Lee 2019-07-07 23:40:53 -07:00 committed by Ilya
parent df8e01e95a
commit 5bc3d15a30

View file

@ -2001,7 +2001,8 @@ namespace Microsoft.PowerShell.Commands
public static string NameString(PSObject instance)
{
return instance?.BaseObject is FileSystemInfo fileInfo
? InternalSymbolicLinkLinkCodeMethods.IsReparsePoint(fileInfo)
? (InternalSymbolicLinkLinkCodeMethods.IsReparsePoint(fileInfo) &&
InternalSymbolicLinkLinkCodeMethods.IsNameSurrogateReparsePoint(fileInfo.FullName))
? $"{fileInfo.Name} -> {InternalSymbolicLinkLinkCodeMethods.GetTarget(instance)}"
: fileInfo.Name
: string.Empty;