Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/System.Private.CoreLib/shared/System/IO/Path.Unix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public static string GetFullPath(string path)
if (path.Length == 0)
throw new ArgumentException(SR.Arg_PathEmpty, nameof(path));

if (path.IndexOf('\0') != -1)
throw new ArgumentException(SR.Argument_InvalidPathChars, nameof(path));

// Expand with current directory if necessary
if (!IsPathRooted(path))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ internal static partial class PathInternal

internal const string ParentDirectoryPrefix = @"../";

/// <summary>Returns a value indicating if the given path contains invalid characters.</summary>
internal static bool HasIllegalCharacters(string path)
{
Debug.Assert(path != null);
return path.IndexOf(InvalidPathChar) >= 0;
}

internal static int GetRootLength(string path)
{
return path.Length > 0 && IsDirectorySeparator(path[0]) ? 1 : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,36 +146,6 @@ internal static bool IsExtended(string path)
&& path[3] == '\\';
}

/// <summary>
/// Returns a value indicating if the given path contains invalid characters (", &lt;, &gt;, |
/// NUL, or any ASCII char whose integer representation is in the range of 1 through 31).
/// Does not check for wild card characters ? and *.
/// </summary>
internal static bool HasIllegalCharacters(string path)
{
// This is equivalent to IndexOfAny(InvalidPathChars) >= 0,
// except faster since IndexOfAny grows slower as the input
// array grows larger.
// Since we know that some of the characters we're looking
// for are contiguous in the alphabet-- the path cannot contain
// characters 0-31-- we can optimize this for our specific use
// case and use simple comparison operations.

for (int i = 0; i < path.Length; i++)
{
char c = path[i];
if (c <= '|') // fast path for common case - '|' is highest illegal character
{
if (c <= '\u001f' || c == '|')
{
return true;
}
}
}

return false;
}

/// <summary>
/// Check for known wildcard characters. '*' and '?' are the most common ones.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace System.Runtime.CompilerServices
{
// Calls to methods or references to fields marked with this attribute may be replaced at
// some call sites with jit intrinsic expansions.
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field, Inherited = false)]
// Types marked with this attribute may be specially treated by the rumtime/compiler.
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field, Inherited = false)]
internal sealed class IntrinsicAttribute : Attribute
{
}
Expand Down