From 5bc3d15a30ccf129d7e3407d1f4c3ca9350ee401 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Sun, 7 Jul 2019 23:40:53 -0700 Subject: [PATCH] Check if a reparsepoint is a symlink before trying to get target (#9895) --- .../namespaces/FileSystemProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/namespaces/FileSystemProvider.cs b/src/System.Management.Automation/namespaces/FileSystemProvider.cs index 9705bbda7..ddfe724fc 100644 --- a/src/System.Management.Automation/namespaces/FileSystemProvider.cs +++ b/src/System.Management.Automation/namespaces/FileSystemProvider.cs @@ -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;