| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// Options that control how a <seealso cref="Uri"/> is created and behaves. |
| | | 8 | | /// </summary> |
| | | 9 | | public struct UriCreationOptions |
| | | 10 | | { |
| | | 11 | | internal Uri.Flags _flags; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets or sets a value that indicates whether absolute file paths in the input are recognized as file URIs. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <value><see langword="true"/> to allow implicit file paths; otherwise, <see langword="false"/>. The default |
| | | 17 | | /// <remarks> |
| | | 18 | | /// DOS and UNC paths are recognized on all operating systems. Unix paths are recognized only on Unix-like opera |
| | | 19 | | /// When this option is <see langword="false"/>, implicit file paths are rejected when an absolute URI is requir |
| | | 20 | | /// </remarks> |
| | | 21 | | public bool AllowImplicitFilePaths |
| | | 22 | | { |
| | 0 | 23 | | readonly get => (_flags & Uri.Flags.DisableImplicitFilePaths) == 0; |
| | 0 | 24 | | set => _flags = value |
| | 0 | 25 | | ? _flags & ~Uri.Flags.DisableImplicitFilePaths |
| | 0 | 26 | | : _flags | Uri.Flags.DisableImplicitFilePaths; |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Disables validation and normalization of the Path and Query. |
| | | 31 | | /// No transformations of the URI past the Authority will take place. |
| | | 32 | | /// <see cref="Uri"/> instances created with this option do not support <see cref="Uri.Fragment"/>s. |
| | | 33 | | /// <see cref="Uri.GetComponents(UriComponents, UriFormat)"/> may not be used for <see cref="UriComponents.Path" |
| | | 34 | | /// Be aware that disabling canonicalization also means that reserved characters will not be escaped, |
| | | 35 | | /// which may corrupt the HTTP request and makes the application subject to request smuggling. |
| | | 36 | | /// Only set this option if you have ensured that the URI string is already sanitized. |
| | | 37 | | /// </summary> |
| | | 38 | | public bool DangerousDisablePathAndQueryCanonicalization |
| | | 39 | | { |
| | 0 | 40 | | readonly get => (_flags & Uri.Flags.DisablePathAndQueryCanonicalization) != 0; |
| | 0 | 41 | | set => _flags = value |
| | 0 | 42 | | ? _flags | Uri.Flags.DisablePathAndQueryCanonicalization |
| | 0 | 43 | | : _flags & ~Uri.Flags.DisablePathAndQueryCanonicalization; |
| | | 44 | | } |
| | | 45 | | } |
| | | 46 | | } |
| | | 47 | | |