You've already forked linux-packaging-mono
Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
parent
1190d13a04
commit
6bdd276d05
87
external/corefx/src/System.Private.Uri/System.Private.Uri.sln
vendored
Normal file
87
external/corefx/src/System.Private.Uri/System.Private.Uri.sln
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{527D1780-0895-4D4F-B54F-257DB1BAC218}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7E12B1D3-7BF1-4E8D-88DD-08218578C095}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Private.Uri", "src\System.Private.Uri.csproj", "{4AC5343E-6E31-4BA5-A795-0493AE7E9008}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{461120FF-E1FB-41E3-9B70-20EE316B45CA}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FunctionalTests", "FunctionalTests", "{F4685A63-70C7-447C-A5E6-BAA26766A8B9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Private.Uri.Tests", "tests\FunctionalTests\System.Private.Uri.Functional.Tests.csproj", "{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Private.Uri.Unit.Tests", "tests\UnitTests\System.Private.Uri.Unit.Tests.csproj", "{0D174EA9-9E61-4519-8D31-7BD2331A1982}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Unix_Debug|Any CPU = Unix_Debug|Any CPU
|
||||
Unix_Release|Any CPU = Unix_Release|Any CPU
|
||||
Windows_Debug|Any CPU = Windows_Debug|Any CPU
|
||||
Windows_Release|Any CPU = Windows_Release|Any CPU
|
||||
Windows_uap101aot_Debug|Any CPU = Windows_uap101aot_Debug|Any CPU
|
||||
Windows_uap101aot_Release|Any CPU = Windows_uap101aot_Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|Any CPU.ActiveCfg = Unix_Debug|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Debug|Any CPU.Build.0 = Unix_Debug|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|Any CPU.ActiveCfg = Unix_Release|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Unix_Release|Any CPU.Build.0 = Unix_Release|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_Debug|Any CPU.ActiveCfg = Windows_Debug|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_Debug|Any CPU.Build.0 = Windows_Debug|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_uap101aot_Debug|Any CPU.ActiveCfg = Windows_uap101aot_Debug|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_uap101aot_Debug|Any CPU.Build.0 = Windows_uap101aot_Debug|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_uap101aot_Release|Any CPU.ActiveCfg = Windows_uap101aot_Release|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_uap101aot_Release|Any CPU.Build.0 = Windows_uap101aot_Release|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_Release|Any CPU.ActiveCfg = Windows_Release|Any CPU
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008}.Windows_Release|Any CPU.Build.0 = Windows_Release|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Unix_Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Unix_Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Unix_Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Unix_Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Windows_Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Windows_Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Windows_uap101aot_Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Windows_uap101aot_Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Windows_uap101aot_Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Windows_uap101aot_Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Windows_Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C}.Windows_Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Unix_Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Unix_Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Unix_Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Unix_Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Windows_Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Windows_Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Windows_uap101aot_Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Windows_uap101aot_Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Windows_uap101aot_Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Windows_uap101aot_Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Windows_Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982}.Windows_Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{4AC5343E-6E31-4BA5-A795-0493AE7E9008} = {527D1780-0895-4D4F-B54F-257DB1BAC218}
|
||||
{461120FF-E1FB-41E3-9B70-20EE316B45CA} = {7E12B1D3-7BF1-4E8D-88DD-08218578C095}
|
||||
{F4685A63-70C7-447C-A5E6-BAA26766A8B9} = {7E12B1D3-7BF1-4E8D-88DD-08218578C095}
|
||||
{B0FFC4A8-BAC3-4A7F-8FD5-5B680209371C} = {F4685A63-70C7-447C-A5E6-BAA26766A8B9}
|
||||
{0D174EA9-9E61-4519-8D31-7BD2331A1982} = {461120FF-E1FB-41E3-9B70-20EE316B45CA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
8
external/corefx/src/System.Private.Uri/dir.props
vendored
Normal file
8
external/corefx/src/System.Private.Uri/dir.props
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\dir.props" />
|
||||
<PropertyGroup>
|
||||
<AssemblyVersion>4.0.4.0</AssemblyVersion>
|
||||
<IsNETCoreApp>true</IsNETCoreApp>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
12
external/corefx/src/System.Private.Uri/src/Configurations.props
vendored
Normal file
12
external/corefx/src/System.Private.Uri/src/Configurations.props
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildConfigurations>
|
||||
uap101aot-Windows_NT;
|
||||
netstandard1.0-Unix;
|
||||
netstandard1.0-Windows_NT;
|
||||
netcoreapp1.2corert-Unix;
|
||||
netcoreapp1.2corert-Windows_NT;
|
||||
</BuildConfigurations>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
4
external/corefx/src/System.Private.Uri/src/FxCopBaseline.cs
vendored
Normal file
4
external/corefx/src/System.Private.Uri/src/FxCopBaseline.cs
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
// TODO: Remove this once https://github.com/dotnet/corefx/issues/13107 is fixed
|
||||
[assembly: SuppressMessage("Microsoft.Reliability", "CA2002:DoNotLockOnObjectsWithWeakIdentity", Scope = "member", Target = "System.Uri.#CreateUriInfo(System.Uri+Flags)")]
|
||||
273
external/corefx/src/System.Private.Uri/src/Resources/Strings.resx
vendored
Normal file
273
external/corefx/src/System.Private.Uri/src/Resources/Strings.resx
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ArgumentOutOfRange_NeedNonNegNum" xml:space="preserve">
|
||||
<value>Non-negative number required.</value>
|
||||
</data>
|
||||
<data name="ArgumentOutOfRange_Index" xml:space="preserve">
|
||||
<value>Index was out of range. Must be non-negative and less than the size of the collection.</value>
|
||||
</data>
|
||||
<data name="ArgumentOutOfRange_IndexCountBuffer" xml:space="preserve">
|
||||
<value>Index and count must refer to a location within the buffer.</value>
|
||||
</data>
|
||||
<data name="Argument_AddingDuplicate" xml:space="preserve">
|
||||
<value>An item with the same key has already been added. Key: {0}</value>
|
||||
</data>
|
||||
<data name="Argument_IdnBadLabelSize" xml:space="preserve">
|
||||
<value>IDN labels must be between 1 and 63 characters long.</value>
|
||||
</data>
|
||||
<data name="Argument_IdnBadPunycode" xml:space="preserve">
|
||||
<value>Invalid IDN encoded string.</value>
|
||||
</data>
|
||||
<data name="Argument_IdnIllegalName" xml:space="preserve">
|
||||
<value>Decoded string is not a valid IDN name.</value>
|
||||
</data>
|
||||
<data name="Argument_InvalidCharSequence" xml:space="preserve">
|
||||
<value>Invalid Unicode code point found at index {0}.</value>
|
||||
</data>
|
||||
<data name="Argument_InvalidCharSequenceNoIndex" xml:space="preserve">
|
||||
<value>String contains invalid Unicode code points.</value>
|
||||
</data>
|
||||
<data name="Argument_InvalidNormalizationForm" xml:space="preserve">
|
||||
<value>Invalid normalization form.</value>
|
||||
</data>
|
||||
<data name="Arg_OutOfMemoryException" xml:space="preserve">
|
||||
<value>Insufficient memory to continue the execution of the program.</value>
|
||||
</data>
|
||||
<data name="UnknownError_Num" xml:space="preserve">
|
||||
<value>Unknown error '{0}'.</value>
|
||||
</data>
|
||||
<data name="net_uri_BadAuthority" xml:space="preserve">
|
||||
<value>Invalid URI: The Authority/Host could not be parsed.</value>
|
||||
</data>
|
||||
<data name="net_uri_BadAuthorityTerminator" xml:space="preserve">
|
||||
<value>Invalid URI: The Authority/Host cannot end with a backslash character ('\\').</value>
|
||||
</data>
|
||||
<data name="net_uri_BadFormat" xml:space="preserve">
|
||||
<value>Invalid URI: The format of the URI could not be determined.</value>
|
||||
</data>
|
||||
<data name="net_uri_NeedFreshParser" xml:space="preserve">
|
||||
<value>The URI parser instance passed into 'uriParser' parameter is already registered with the scheme name '{0}'.</value>
|
||||
</data>
|
||||
<data name="net_uri_AlreadyRegistered" xml:space="preserve">
|
||||
<value>A URI scheme name '{0}' already has a registered custom parser.</value>
|
||||
</data>
|
||||
<data name="net_uri_BadHostName" xml:space="preserve">
|
||||
<value>Invalid URI: The hostname could not be parsed.</value>
|
||||
</data>
|
||||
<data name="net_uri_BadPort" xml:space="preserve">
|
||||
<value>Invalid URI: Invalid port specified.</value>
|
||||
</data>
|
||||
<data name="net_uri_BadScheme" xml:space="preserve">
|
||||
<value>Invalid URI: The URI scheme is not valid.</value>
|
||||
</data>
|
||||
<data name="net_uri_BadString" xml:space="preserve">
|
||||
<value>Invalid URI: There is an invalid sequence in the string.</value>
|
||||
</data>
|
||||
<data name="net_uri_BadUserPassword" xml:space="preserve">
|
||||
<value>Invalid URI: The username:password construct is badly formed.</value>
|
||||
</data>
|
||||
<data name="net_uri_CannotCreateRelative" xml:space="preserve">
|
||||
<value>A relative URI cannot be created because the 'uriString' parameter represents an absolute URI.</value>
|
||||
</data>
|
||||
<data name="net_uri_SchemeLimit" xml:space="preserve">
|
||||
<value>Invalid URI: The Uri scheme is too long.</value>
|
||||
</data>
|
||||
<data name="net_uri_EmptyUri" xml:space="preserve">
|
||||
<value>Invalid URI: The URI is empty.</value>
|
||||
</data>
|
||||
<data name="net_uri_InvalidUriKind" xml:space="preserve">
|
||||
<value>The value '{0}' passed for the UriKind parameter is invalid.</value>
|
||||
</data>
|
||||
<data name="net_uri_MustRootedPath" xml:space="preserve">
|
||||
<value>Invalid URI: A Dos path must be rooted, for example, 'c:\\'.</value>
|
||||
</data>
|
||||
<data name="net_uri_NotAbsolute" xml:space="preserve">
|
||||
<value>This operation is not supported for a relative URI.</value>
|
||||
</data>
|
||||
<data name="net_uri_PortOutOfRange" xml:space="preserve">
|
||||
<value>A derived type '{0}' has reported an invalid value for the Uri port '{1}'.</value>
|
||||
</data>
|
||||
<data name="net_uri_SizeLimit" xml:space="preserve">
|
||||
<value>Invalid URI: The Uri string is too long.</value>
|
||||
</data>
|
||||
<data name="net_uri_UserDrivenParsing" xml:space="preserve">
|
||||
<value>A derived type '{0}' is responsible for parsing this Uri instance. The base implementation must not be used.</value>
|
||||
</data>
|
||||
<data name="net_uri_NotJustSerialization" xml:space="preserve">
|
||||
<value>UriComponents.SerializationInfoString must not be combined with other UriComponents.</value>
|
||||
</data>
|
||||
<data name="net_uri_BadUnicodeHostForIdn" xml:space="preserve">
|
||||
<value>An invalid Unicode character by IDN standards was specified in the host.</value>
|
||||
</data>
|
||||
<data name="AssertionFailed" xml:space="preserve">
|
||||
<value>Assertion failed.</value>
|
||||
</data>
|
||||
<data name="Debug_Fail" xml:space="preserve">
|
||||
<value>Fail: {0}</value>
|
||||
</data>
|
||||
<data name="DebugAssertBanner" xml:space="preserve">
|
||||
<value>---- DEBUG ASSERTION FAILED ----</value>
|
||||
</data>
|
||||
<data name="DebugAssertLongMessage" xml:space="preserve">
|
||||
<value>---- Assert Long Message ----</value>
|
||||
</data>
|
||||
<data name="DebugAssertShortMessage" xml:space="preserve">
|
||||
<value>---- Assert Short Message ----</value>
|
||||
</data>
|
||||
<data name="IO_FileNotFound" xml:space="preserve">
|
||||
<value>Unable to find the specified file.</value>
|
||||
</data>
|
||||
<data name="IO_FileNotFound_FileName" xml:space="preserve">
|
||||
<value>Could not find file '{0}'.</value>
|
||||
</data>
|
||||
<data name="IO_PathNotFound_NoPathName" xml:space="preserve">
|
||||
<value>Could not find a part of the path.</value>
|
||||
</data>
|
||||
<data name="IO_PathNotFound_Path" xml:space="preserve">
|
||||
<value>Could not find a part of the path '{0}'.</value>
|
||||
</data>
|
||||
<data name="IO_SharingViolation_File" xml:space="preserve">
|
||||
<value>The process cannot access the file '{0}' because it is being used by another process.</value>
|
||||
</data>
|
||||
<data name="IO_SharingViolation_NoFileName" xml:space="preserve">
|
||||
<value>The process cannot access the file because it is being used by another process.</value>
|
||||
</data>
|
||||
<data name="UnauthorizedAccess_IODenied_NoPathName" xml:space="preserve">
|
||||
<value>Access to the path is denied.</value>
|
||||
</data>
|
||||
<data name="UnauthorizedAccess_IODenied_Path" xml:space="preserve">
|
||||
<value>Access to the path '{0}' is denied.</value>
|
||||
</data>
|
||||
<data name="ArgumentOutOfRange_FileLengthTooBig" xml:space="preserve">
|
||||
<value>Specified file length was too large for the file system.</value>
|
||||
</data>
|
||||
<data name="IO_FileExists_Name" xml:space="preserve">
|
||||
<value>The file '{0}' already exists.</value>
|
||||
</data>
|
||||
<data name="IO_PathTooLong" xml:space="preserve">
|
||||
<value>The specified file name or path is too long, or a component of the specified path is too long.</value>
|
||||
</data>
|
||||
<data name="Argument_ExtraNotValid" xml:space="preserve">
|
||||
<value>Extra portion of URI not valid.</value>
|
||||
</data>
|
||||
<data name="Argument_InvalidUriSubcomponent" xml:space="preserve">
|
||||
<value>The subcomponent, {0}, of this uri is not valid.</value>
|
||||
</data>
|
||||
</root>
|
||||
12
external/corefx/src/System.Private.Uri/src/Resources/System.Private.Uri.rd.xml
vendored
Normal file
12
external/corefx/src/System.Private.Uri/src/Resources/System.Private.Uri.rd.xml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Library Name="*System.Private.Uri*">
|
||||
<Assembly Name="System.Private.Uri">
|
||||
<Namespace Name="System">
|
||||
<!-- System.Uri is handled internally in the DCS and DCJS serializer, and it cannot be specified as a serialization root -->
|
||||
<Type Name="Uri" DataContractJsonSerializer="Excluded" DataContractSerializer="Excluded"/>
|
||||
</Namespace>
|
||||
</Assembly>
|
||||
</Library>
|
||||
</Directives>
|
||||
|
||||
125
external/corefx/src/System.Private.Uri/src/System.Private.Uri.csproj
vendored
Normal file
125
external/corefx/src/System.Private.Uri/src/System.Private.Uri.csproj
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{4AC5343E-6E31-4BA5-A795-0493AE7E9008}</ProjectGuid>
|
||||
<AssemblyName>System.Private.Uri</AssemblyName>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<!-- Suppress warnings for type conflicts between SafeFileHandle in partial facade and mscorlib -->
|
||||
<NoWarn>0436</NoWarn>
|
||||
<SkipCommonResourcesIncludes Condition="'$(TargetGroup)'=='uap101aot' or '$(TargetGroup)' == 'netcoreapp1.2corert'">true</SkipCommonResourcesIncludes>
|
||||
<DefineConstants Condition="'$(TargetGroup)'=='netstandard1.0'">$(DefineConstants);netstandard10</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<!-- Default configurations to help VS understand the configurations -->
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='uap101aot-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='uap101aot-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.0-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.0-Unix-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.0-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netstandard1.0-Windows_NT-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp1.2corert-Unix-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp1.2corert-Unix-Release|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp1.2corert-Windows_NT-Debug|AnyCPU'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='netcoreapp1.2corert-Windows_NT-Release|AnyCPU'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="$(CommonPath)\System\Diagnostics\Debug.cs" Condition="'$(TargetGroup)'!='uap101aot' and '$(TargetGroup)' != 'netcoreapp1.2corert'">
|
||||
<Link>Common\System\Diagnostics\Debug.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\Collections\Generic\ArrayBuilder.cs">
|
||||
<Link>Common\System\Collections\Generic\ArrayBuilder.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\Collections\Generic\LowLevelDictionary.cs">
|
||||
<Link>Common\System\Collections\Generic\LowLevelDictionary.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FxCopBaseline.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="System\DomainNameHelper.cs" />
|
||||
<Compile Include="System\GenericUriParser.cs" />
|
||||
<Compile Include="System\IPv4AddressHelper.cs" />
|
||||
<Compile Include="System\IPv6AddressHelper.cs" />
|
||||
<Compile Include="System\IriHelper.cs" />
|
||||
<Compile Include="System\UncNameHelper.cs" />
|
||||
<Compile Include="System\Uri.cs" />
|
||||
<Compile Include="System\UriBuilder.cs" />
|
||||
<Compile Include="System\UriEnumTypes.cs" />
|
||||
<Compile Include="System\UriExt.cs" />
|
||||
<Compile Include="System\UriFormatException.cs" />
|
||||
<Compile Include="System\UriHelper.cs" />
|
||||
<Compile Include="System\UriHostNameType.cs" />
|
||||
<Compile Include="System\UriParserTemplates.cs" />
|
||||
<Compile Include="System\UriPartial.cs" />
|
||||
<Compile Include="System\UriScheme.cs" />
|
||||
<Compile Include="System\UriSyntax.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetsWindows)' == 'true' and '$(TargetGroup)'=='netstandard1.0'">
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\Interop.Libraries.cs">
|
||||
<Link>Common\Interop\Windows\Interop.Libraries.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Windows\kernel32\Interop.OutputDebugString.cs">
|
||||
<Link>Common\Interop\Windows\kernel32\Interop.OutputDebugString.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\Diagnostics\Debug.Windows.cs">
|
||||
<Link>Common\System\Diagnostics\Debug.Windows.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetsUnix)' == 'true' and '$(TargetGroup)' == 'netstandard1.0'">
|
||||
<Compile Include="$(CommonPath)\System\Diagnostics\Debug.Unix.cs">
|
||||
<Link>Common\System\Diagnostics\Debug.Unix.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\Interop.Libraries.cs">
|
||||
<Link>Common\Interop\Unix\Interop.Libraries.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\Interop.Errors.cs">
|
||||
<Link>Common\Interop\Unix\Interop.Errors.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\Interop.IOErrors.cs">
|
||||
<Link>Common\Interop\Unix\Interop.IOErrors.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Close.cs">
|
||||
<Link>Common\Interop\Unix\System.Native\Interop.Close.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Dup.cs">
|
||||
<Link>Common\Interop\Unix\Interop.Dup.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.FileDescriptors.cs">
|
||||
<Link>Common\Interop\Unix\Interop.FileDescriptors.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.FLock.cs">
|
||||
<Link>Common\Interop\Unix\Interop.FLock.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Open.cs">
|
||||
<Link>Common\Interop\Unix\System.Native\Interop.Open.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.OpenFlags.cs">
|
||||
<Link>Common\Interop\Unix\System.Native\Interop.OpenFlags.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.SysLog.cs">
|
||||
<Link>Common\Interop\Unix\libc\Interop.SysLog.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Write.cs">
|
||||
<Link>Common\Interop\Unix\libc\Interop.Write.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Stat.cs">
|
||||
<Link>Common\Interop\Unix\Interop.Stat.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\Microsoft\Win32\SafeHandles\SafeFileHandleHelper.Unix.cs">
|
||||
<Link>Common\Microsoft\Win32\SafeHandles\SafeFileHandleHelper.Unix.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)'=='uap101aot' or '$(TargetGroup)' == 'netcoreapp1.2corert'">
|
||||
<EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" />
|
||||
<Compile Include="$(CommonPath)\System\SR.Core.cs">
|
||||
<Link>Common\System\SR.Core.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(CommonPath)\System\Resources\NeutralResourcesLanguageAttribute.cs">
|
||||
<Link>Common\System\Resources\NeutralResourcesLanguageAttribute.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ReferenceFromRuntime Include="System.Private.CoreLib" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
538
external/corefx/src/System.Private.Uri/src/System/DomainNameHelper.cs
vendored
Normal file
538
external/corefx/src/System.Private.Uri/src/System/DomainNameHelper.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
144
external/corefx/src/System.Private.Uri/src/System/GenericUriParser.cs
vendored
Normal file
144
external/corefx/src/System.Private.Uri/src/System/GenericUriParser.cs
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace System {
|
||||
|
||||
//
|
||||
// This enum specifies the public options used to customize a hierarchical built-in parser.
|
||||
//
|
||||
[Flags]
|
||||
public enum GenericUriParserOptions
|
||||
{
|
||||
// A hierarchical URI, allows a userinfo, non empty Inet-based authority, path, query and fragment
|
||||
// The URI path gets agressively compressed means dots, slashes and backslashes are unescaped,
|
||||
// backslashesare converted, and then it compresses the path. It also removes trailing dots,
|
||||
// empty segments and dots-only segments
|
||||
Default = 0x0,
|
||||
|
||||
// Allows a free style authority that would terminate with '/'
|
||||
GenericAuthority = 0x1,
|
||||
|
||||
// Allows an empty authority foo:///
|
||||
AllowEmptyAuthority = 0x2,
|
||||
|
||||
// Disables a user info component, it implied in the case of GenericAuthority flag
|
||||
NoUserInfo = 0x4,
|
||||
|
||||
// Disables a port component, it is implied in the case of GenericAuthority flag
|
||||
NoPort = 0x8,
|
||||
|
||||
// Disables a query. A ? char is considered as part of the path and is escaped
|
||||
NoQuery = 0x10,
|
||||
|
||||
// Disables a fragment. A # char is considered as part of the path or query and is escaped
|
||||
NoFragment = 0x20,
|
||||
|
||||
// if false then converta \ to /, otheriwse does this conversion for the Path component.
|
||||
DontConvertPathBackslashes = 0x40,
|
||||
|
||||
// if false, then a/./b or a/.../b becomes a/b and /a/../b becomes /b
|
||||
DontCompressPath = 0x80,
|
||||
|
||||
// if false then a/%2e./b becomes a/../b and then usually compressed
|
||||
DontUnescapePathDotsAndSlashes= 0x100,
|
||||
|
||||
// IDN hosts supported. if true then unicode hostname is converted to IDN host
|
||||
// and vice versa
|
||||
Idn = 0x200,
|
||||
|
||||
// Iri strict parsing flag. Makes sense for Unicode. If true then string is
|
||||
// normalized, bidi control characters are removed, unicode char limits are checked
|
||||
IriParsing = 0x400
|
||||
}
|
||||
|
||||
public class GenericUriParser: UriParser
|
||||
{
|
||||
public GenericUriParser(GenericUriParserOptions options) : base(MapGenericParserOptions(options))
|
||||
{
|
||||
}
|
||||
|
||||
private static UriSyntaxFlags MapGenericParserOptions(GenericUriParserOptions options)
|
||||
{
|
||||
//
|
||||
// Here we map public flags to internal ones
|
||||
// Note an instacne of this parser is always a "simple parser" since the class is sealed.
|
||||
//
|
||||
UriSyntaxFlags flags = DefaultGenericUriParserFlags;
|
||||
|
||||
if ((options & GenericUriParserOptions.GenericAuthority) != 0)
|
||||
{
|
||||
// Disable some options that are not compatible with generic authority
|
||||
flags &= ~(UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.AllowAnInternetHost);
|
||||
flags |= UriSyntaxFlags.AllowAnyOtherHost;
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.AllowEmptyAuthority) != 0)
|
||||
{
|
||||
flags |= UriSyntaxFlags.AllowEmptyHost;
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.NoUserInfo) != 0)
|
||||
{
|
||||
flags &= ~UriSyntaxFlags.MayHaveUserInfo;
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.NoPort) != 0)
|
||||
{
|
||||
flags &= ~UriSyntaxFlags.MayHavePort;
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.NoQuery) != 0)
|
||||
{
|
||||
flags &= ~UriSyntaxFlags.MayHaveQuery;
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.NoFragment) != 0)
|
||||
{
|
||||
flags &= ~UriSyntaxFlags.MayHaveFragment;
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.DontConvertPathBackslashes) != 0)
|
||||
{
|
||||
flags &= ~UriSyntaxFlags.ConvertPathSlashes;
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.DontCompressPath) != 0)
|
||||
{
|
||||
flags &= ~(UriSyntaxFlags.CompressPath | UriSyntaxFlags.CanonicalizeAsFilePath);
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.DontUnescapePathDotsAndSlashes) != 0)
|
||||
{
|
||||
flags &= ~UriSyntaxFlags.UnEscapeDotsAndSlashes;
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.Idn) != 0)
|
||||
{
|
||||
flags |= UriSyntaxFlags.AllowIdn;
|
||||
}
|
||||
|
||||
if ((options & GenericUriParserOptions.IriParsing) != 0)
|
||||
{
|
||||
flags |= UriSyntaxFlags.AllowIriParsing;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
private const UriSyntaxFlags DefaultGenericUriParserFlags =
|
||||
UriSyntaxFlags.MustHaveAuthority |
|
||||
UriSyntaxFlags.MayHaveUserInfo |
|
||||
UriSyntaxFlags.MayHavePort |
|
||||
UriSyntaxFlags.MayHavePath |
|
||||
UriSyntaxFlags.MayHaveQuery |
|
||||
UriSyntaxFlags.MayHaveFragment |
|
||||
UriSyntaxFlags.AllowUncHost |
|
||||
UriSyntaxFlags.AllowAnInternetHost |
|
||||
UriSyntaxFlags.PathIsRooted |
|
||||
UriSyntaxFlags.ConvertPathSlashes |
|
||||
UriSyntaxFlags.CompressPath |
|
||||
UriSyntaxFlags.CanonicalizeAsFilePath |
|
||||
UriSyntaxFlags.UnEscapeDotsAndSlashes;
|
||||
}
|
||||
}
|
||||
370
external/corefx/src/System.Private.Uri/src/System/IPv4AddressHelper.cs
vendored
Normal file
370
external/corefx/src/System.Private.Uri/src/System/IPv4AddressHelper.cs
vendored
Normal file
@@ -0,0 +1,370 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System
|
||||
{
|
||||
// The class designed as to keep minimal the working set of Uri class.
|
||||
// The idea is to stay with static helper methods and strings
|
||||
internal static class IPv4AddressHelper
|
||||
{
|
||||
internal const long Invalid = -1;
|
||||
// Note: the native parser cannot handle MaxIPv4Value, only MaxIPv4Value - 1
|
||||
private const long MaxIPv4Value = UInt32.MaxValue;
|
||||
private const int Octal = 8;
|
||||
private const int Decimal = 10;
|
||||
private const int Hex = 16;
|
||||
|
||||
private const int NumberOfLabels = 4;
|
||||
|
||||
// methods
|
||||
// Parse and canonicalize
|
||||
internal static string ParseCanonicalName(string str, int start, int end, ref bool isLoopback)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
byte* numbers = stackalloc byte[NumberOfLabels];
|
||||
isLoopback = Parse(str, numbers, start, end);
|
||||
return numbers[0] + "." + numbers[1] + "." + numbers[2] + "." + numbers[3];
|
||||
}
|
||||
}
|
||||
|
||||
// Only called from the IPv6Helper, only parse the canonical format
|
||||
internal static int ParseHostNumber(string str, int start, int end)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
byte* numbers = stackalloc byte[NumberOfLabels];
|
||||
ParseCanonical(str, numbers, start, end);
|
||||
return (numbers[0] << 24) + (numbers[1] << 16) + (numbers[2] << 8) + numbers[3];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// IsValid
|
||||
//
|
||||
// Performs IsValid on a substring. Updates the index to where we
|
||||
// believe the IPv4 address ends
|
||||
//
|
||||
// Inputs:
|
||||
// <argument> name
|
||||
// string containing possible IPv4 address
|
||||
//
|
||||
// <argument> start
|
||||
// offset in <name> to start checking for IPv4 address
|
||||
//
|
||||
// <argument> end
|
||||
// offset in <name> of the last character we can touch in the check
|
||||
//
|
||||
// Outputs:
|
||||
// <argument> end
|
||||
// index of last character in <name> we checked
|
||||
//
|
||||
// <argument> allowIPv6
|
||||
// enables parsing IPv4 addresses embedded in IPv6 address literals
|
||||
//
|
||||
// <argument> notImplicitFile
|
||||
// do not consider this URI holding an implicit filename
|
||||
//
|
||||
// <argument> unknownScheme
|
||||
// the check is made on an unknown scheme (suppress IPv4 canonicalization)
|
||||
//
|
||||
// Assumes:
|
||||
// The address string is terminated by either
|
||||
// end of the string, characters ':' '/' '\' '?'
|
||||
//
|
||||
//
|
||||
// Returns:
|
||||
// bool
|
||||
//
|
||||
// Throws:
|
||||
// Nothing
|
||||
//
|
||||
|
||||
//Remark: MUST NOT be used unless all input indexes are verified and trusted.
|
||||
internal static unsafe bool IsValid(char* name, int start, ref int end, bool allowIPv6, bool notImplicitFile, bool unknownScheme)
|
||||
{
|
||||
// IPv6 can only have canonical IPv4 embedded. Unknown schemes will not attempt parsing of non-canonical IPv4 addresses.
|
||||
if (allowIPv6 || unknownScheme)
|
||||
{
|
||||
return IsValidCanonical(name, start, ref end, allowIPv6, notImplicitFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ParseNonCanonical(name, start, ref end, notImplicitFile) != Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// IsValidCanonical
|
||||
//
|
||||
// Checks if the substring is a valid canonical IPv4 address or an IPv4 address embedded in an IPv6 literal
|
||||
// This is an attempt to parse ABNF productions from RFC3986, Section 3.2.2:
|
||||
// IP-literal = "[" ( IPv6address / IPvFuture ) "]"
|
||||
// IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
|
||||
// dec-octet = DIGIT ; 0-9
|
||||
// / %x31-39 DIGIT ; 10-99
|
||||
// / "1" 2DIGIT ; 100-199
|
||||
// / "2" %x30-34 DIGIT ; 200-249
|
||||
// / "25" %x30-35 ; 250-255
|
||||
//
|
||||
internal static unsafe bool IsValidCanonical(char* name, int start, ref int end, bool allowIPv6, bool notImplicitFile)
|
||||
{
|
||||
int dots = 0;
|
||||
int number = 0;
|
||||
bool haveNumber = false;
|
||||
bool firstCharIsZero = false;
|
||||
|
||||
while (start < end)
|
||||
{
|
||||
char ch = name[start];
|
||||
if (allowIPv6)
|
||||
{
|
||||
// for ipv4 inside ipv6 the terminator is either ScopeId, prefix or ipv6 terminator
|
||||
if (ch == ']' || ch == '/' || ch == '%') break;
|
||||
}
|
||||
else if (ch == '/' || ch == '\\' || (notImplicitFile && (ch == ':' || ch == '?' || ch == '#')))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (ch <= '9' && ch >= '0')
|
||||
{
|
||||
if (!haveNumber && (ch == '0'))
|
||||
{
|
||||
if ((start + 1 < end) && name[start + 1] == '0')
|
||||
{
|
||||
// 00 is not allowed as a prefix.
|
||||
return false;
|
||||
}
|
||||
|
||||
firstCharIsZero = true;
|
||||
}
|
||||
|
||||
haveNumber = true;
|
||||
number = number * 10 + (name[start] - '0');
|
||||
if (number > 255)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (ch == '.')
|
||||
{
|
||||
if (!haveNumber || (number > 0 && firstCharIsZero))
|
||||
{
|
||||
// 0 is not allowed to prefix a number.
|
||||
return false;
|
||||
}
|
||||
++dots;
|
||||
haveNumber = false;
|
||||
number = 0;
|
||||
firstCharIsZero = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
++start;
|
||||
}
|
||||
bool res = (dots == 3) && haveNumber;
|
||||
if (res)
|
||||
{
|
||||
end = start;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Parse any canonical or non-canonical IPv4 formats and return a long between 0 and MaxIPv4Value.
|
||||
// Return Invalid (-1) for failures.
|
||||
// If the address has less than three dots, only the rightmost section is assumed to contain the combined value for
|
||||
// the missing sections: 0xFF00FFFF == 0xFF.0x00.0xFF.0xFF == 0xFF.0xFFFF
|
||||
internal static unsafe long ParseNonCanonical(char* name, int start, ref int end, bool notImplicitFile)
|
||||
{
|
||||
int numberBase = Decimal;
|
||||
char ch;
|
||||
long[] parts = new long[4];
|
||||
long currentValue = 0;
|
||||
bool atLeastOneChar = false;
|
||||
|
||||
// Parse one dotted section at a time
|
||||
int dotCount = 0; // Limit 3
|
||||
int current = start;
|
||||
for (; current < end; current++)
|
||||
{
|
||||
ch = name[current];
|
||||
currentValue = 0;
|
||||
|
||||
// Figure out what base this section is in
|
||||
numberBase = Decimal;
|
||||
if (ch == '0')
|
||||
{
|
||||
numberBase = Octal;
|
||||
current++;
|
||||
atLeastOneChar = true;
|
||||
if (current < end)
|
||||
{
|
||||
ch = name[current];
|
||||
if (ch == 'x' || ch == 'X')
|
||||
{
|
||||
numberBase = Hex;
|
||||
current++;
|
||||
atLeastOneChar = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse this section
|
||||
for (; current < end; current++)
|
||||
{
|
||||
ch = name[current];
|
||||
int digitValue;
|
||||
|
||||
if ((numberBase == Decimal || numberBase == Hex) && '0' <= ch && ch <= '9')
|
||||
{
|
||||
digitValue = ch - '0';
|
||||
}
|
||||
else if (numberBase == Octal && '0' <= ch && ch <= '7')
|
||||
{
|
||||
digitValue = ch - '0';
|
||||
}
|
||||
else if (numberBase == Hex && 'a' <= ch && ch <= 'f')
|
||||
{
|
||||
digitValue = ch + 10 - 'a';
|
||||
}
|
||||
else if (numberBase == Hex && 'A' <= ch && ch <= 'F')
|
||||
{
|
||||
digitValue = ch + 10 - 'A';
|
||||
}
|
||||
else
|
||||
{
|
||||
break; // Invalid/terminator
|
||||
}
|
||||
|
||||
currentValue = (currentValue * numberBase) + digitValue;
|
||||
|
||||
if (currentValue > MaxIPv4Value) // Overflow
|
||||
{
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
atLeastOneChar = true;
|
||||
}
|
||||
|
||||
if (current < end && name[current] == '.')
|
||||
{
|
||||
if (dotCount >= 3 // Max of 3 dots and 4 segments
|
||||
|| !atLeastOneChar // No empty segments: 1...1
|
||||
// Only the last segment can be more than 255 (if there are less than 3 dots)
|
||||
|| currentValue > 0xFF)
|
||||
{
|
||||
return Invalid;
|
||||
}
|
||||
parts[dotCount] = currentValue;
|
||||
dotCount++;
|
||||
atLeastOneChar = false;
|
||||
continue;
|
||||
}
|
||||
// We don't get here unless We find an invalid character or a terminator
|
||||
break;
|
||||
}
|
||||
|
||||
// Terminators
|
||||
if (!atLeastOneChar)
|
||||
{
|
||||
return Invalid; // Empty trailing segment: 1.1.1.
|
||||
}
|
||||
else if (current >= end)
|
||||
{
|
||||
// end of string, allowed
|
||||
}
|
||||
else if ((ch = name[current]) == '/' || ch == '\\' || (notImplicitFile && (ch == ':' || ch == '?' || ch == '#')))
|
||||
{
|
||||
end = current;
|
||||
}
|
||||
else
|
||||
{
|
||||
// not a valid terminating character
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
parts[dotCount] = currentValue;
|
||||
|
||||
// Parsed, reassemble and check for overflows
|
||||
switch (dotCount)
|
||||
{
|
||||
case 0: // 0xFFFFFFFF
|
||||
if (parts[0] > MaxIPv4Value)
|
||||
{
|
||||
return Invalid;
|
||||
}
|
||||
return parts[0];
|
||||
case 1: // 0xFF.0xFFFFFF
|
||||
if (parts[1] > 0xffffff)
|
||||
{
|
||||
return Invalid;
|
||||
}
|
||||
return (parts[0] << 24) | (parts[1] & 0xffffff);
|
||||
case 2: // 0xFF.0xFF.0xFFFF
|
||||
if (parts[2] > 0xffff)
|
||||
{
|
||||
return Invalid;
|
||||
}
|
||||
return (parts[0] << 24) | ((parts[1] & 0xff) << 16) | (parts[2] & 0xffff);
|
||||
case 3: // 0xFF.0xFF.0xFF.0xFF
|
||||
if (parts[3] > 0xff)
|
||||
{
|
||||
return Invalid;
|
||||
}
|
||||
return (parts[0] << 24) | ((parts[1] & 0xff) << 16) | ((parts[2] & 0xff) << 8) | (parts[3] & 0xff);
|
||||
default:
|
||||
return Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Parse
|
||||
//
|
||||
// Convert this IPv4 address into a sequence of 4 8-bit numbers
|
||||
//
|
||||
private static unsafe bool Parse(string name, byte* numbers, int start, int end)
|
||||
{
|
||||
fixed (char* ipString = name)
|
||||
{
|
||||
int changedEnd = end;
|
||||
long result = IPv4AddressHelper.ParseNonCanonical(ipString, start, ref changedEnd, true);
|
||||
// end includes ports, so changedEnd may be different from end
|
||||
Debug.Assert(result != Invalid, "Failed to parse after already validated: " + name);
|
||||
|
||||
numbers[0] = (byte)(result >> 24);
|
||||
numbers[1] = (byte)(result >> 16);
|
||||
numbers[2] = (byte)(result >> 8);
|
||||
numbers[3] = (byte)(result);
|
||||
}
|
||||
|
||||
return numbers[0] == 127;
|
||||
}
|
||||
|
||||
// Assumes:
|
||||
// <Name> has been validated and contains only decimal digits in groups
|
||||
// of 8-bit numbers and the characters '.'
|
||||
// Address may terminate with ':' or with the end of the string
|
||||
//
|
||||
private static unsafe bool ParseCanonical(string name, byte* numbers, int start, int end)
|
||||
{
|
||||
for (int i = 0; i < NumberOfLabels; ++i)
|
||||
{
|
||||
byte b = 0;
|
||||
char ch;
|
||||
for (; (start < end) && (ch = name[start]) != '.' && ch != ':'; ++start)
|
||||
{
|
||||
b = (byte)(b * 10 + (byte)(ch - '0'));
|
||||
}
|
||||
numbers[i] = b;
|
||||
++start;
|
||||
}
|
||||
return numbers[0] == 127;
|
||||
}
|
||||
}
|
||||
}
|
||||
593
external/corefx/src/System.Private.Uri/src/System/IPv6AddressHelper.cs
vendored
Normal file
593
external/corefx/src/System.Private.Uri/src/System/IPv6AddressHelper.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
365
external/corefx/src/System.Private.Uri/src/System/IriHelper.cs
vendored
Normal file
365
external/corefx/src/System.Private.Uri/src/System/IriHelper.cs
vendored
Normal file
@@ -0,0 +1,365 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace System
|
||||
{
|
||||
internal static class IriHelper
|
||||
{
|
||||
//
|
||||
// Checks if provided non surrogate char lies in iri range
|
||||
//
|
||||
internal static bool CheckIriUnicodeRange(char unicode, bool isQuery)
|
||||
{
|
||||
return ((unicode >= '\u00A0' && unicode <= '\uD7FF') ||
|
||||
(unicode >= '\uF900' && unicode <= '\uFDCF') ||
|
||||
(unicode >= '\uFDF0' && unicode <= '\uFFEF') ||
|
||||
(isQuery && unicode >= '\uE000' && unicode <= '\uF8FF'));
|
||||
}
|
||||
|
||||
//
|
||||
// Check if highSurr and lowSurr are a surrogate pair then
|
||||
// it checks if the combined char is in the range
|
||||
// Takes in isQuery because iri restrictions for query are different
|
||||
//
|
||||
internal static bool CheckIriUnicodeRange(char highSurr, char lowSurr, ref bool surrogatePair, bool isQuery)
|
||||
{
|
||||
bool inRange = false;
|
||||
surrogatePair = false;
|
||||
|
||||
Debug.Assert(char.IsHighSurrogate(highSurr));
|
||||
|
||||
if (char.IsSurrogatePair(highSurr, lowSurr))
|
||||
{
|
||||
surrogatePair = true;
|
||||
char[] chars = new char[2] { highSurr, lowSurr };
|
||||
string surrPair = new string(chars);
|
||||
if (((string.CompareOrdinal(surrPair, "\U00010000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0001FFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U00020000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0002FFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U00030000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0003FFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U00040000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0004FFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U00050000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0005FFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U00060000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0006FFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U00070000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0007FFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U00080000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0008FFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U00090000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0009FFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U000A0000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U000AFFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U000B0000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U000BFFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U000C0000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U000CFFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U000D0000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U000DFFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U000E1000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U000EFFFD") <= 0)) ||
|
||||
(isQuery &&
|
||||
(((string.CompareOrdinal(surrPair, "\U000F0000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U000FFFFD") <= 0)) ||
|
||||
((string.CompareOrdinal(surrPair, "\U00100000") >= 0)
|
||||
&& (string.CompareOrdinal(surrPair, "\U0010FFFD") <= 0)))))
|
||||
{
|
||||
inRange = true;
|
||||
}
|
||||
}
|
||||
|
||||
return inRange;
|
||||
}
|
||||
|
||||
//
|
||||
// Check reserved chars according to RFC 3987 in a specific component
|
||||
//
|
||||
internal static bool CheckIsReserved(char ch, UriComponents component)
|
||||
{
|
||||
if ((component != UriComponents.Scheme) &&
|
||||
(component != UriComponents.UserInfo) &&
|
||||
(component != UriComponents.Host) &&
|
||||
(component != UriComponents.Port) &&
|
||||
(component != UriComponents.Path) &&
|
||||
(component != UriComponents.Query) &&
|
||||
(component != UriComponents.Fragment)
|
||||
)
|
||||
{
|
||||
return (component == (UriComponents)0) ? UriHelper.IsGenDelim(ch) : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (component)
|
||||
{
|
||||
// Reserved chars according to RFC 3987
|
||||
case UriComponents.UserInfo:
|
||||
if (ch == '/' || ch == '?' || ch == '#' || ch == '[' || ch == ']' || ch == '@')
|
||||
return true;
|
||||
break;
|
||||
case UriComponents.Host:
|
||||
if (ch == ':' || ch == '/' || ch == '?' || ch == '#' || ch == '[' || ch == ']' || ch == '@')
|
||||
return true;
|
||||
break;
|
||||
case UriComponents.Path:
|
||||
if (ch == '/' || ch == '?' || ch == '#' || ch == '[' || ch == ']')
|
||||
return true;
|
||||
break;
|
||||
case UriComponents.Query:
|
||||
if (ch == '#' || ch == '[' || ch == ']')
|
||||
return true;
|
||||
break;
|
||||
case UriComponents.Fragment:
|
||||
if (ch == '#' || ch == '[' || ch == ']')
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// IRI normalization for strings containing characters that are not allowed or
|
||||
// escaped characters that should be unescaped in the context of the specified Uri component.
|
||||
//
|
||||
internal static unsafe string EscapeUnescapeIri(char* pInput, int start, int end, UriComponents component)
|
||||
{
|
||||
char[] dest = new char[end - start];
|
||||
byte[] bytes = null;
|
||||
|
||||
// Pin the array to do pointer accesses
|
||||
GCHandle destHandle = GCHandle.Alloc(dest, GCHandleType.Pinned);
|
||||
char* pDest = (char*)destHandle.AddrOfPinnedObject();
|
||||
|
||||
const int percentEncodingLen = 3; // Escaped UTF-8 will take 3 chars: %AB.
|
||||
const int bufferCapacityIncrease = 30 * percentEncodingLen;
|
||||
int bufferRemaining = 0;
|
||||
|
||||
int next = start;
|
||||
int destOffset = 0;
|
||||
char ch;
|
||||
bool escape = false;
|
||||
bool surrogatePair = false;
|
||||
|
||||
for (; next < end; ++next)
|
||||
{
|
||||
escape = false;
|
||||
surrogatePair = false;
|
||||
|
||||
if ((ch = pInput[next]) == '%')
|
||||
{
|
||||
if (next + 2 < end)
|
||||
{
|
||||
ch = UriHelper.EscapedAscii(pInput[next + 1], pInput[next + 2]);
|
||||
|
||||
// Do not unescape a reserved char
|
||||
if (ch == Uri.c_DummyChar || ch == '%' || CheckIsReserved(ch, component) || UriHelper.IsNotSafeForUnescape(ch))
|
||||
{
|
||||
// keep as is
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
pDest[destOffset++] = pInput[next++];
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
pDest[destOffset++] = pInput[next++];
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
pDest[destOffset++] = pInput[next];
|
||||
continue;
|
||||
}
|
||||
else if (ch <= '\x7F')
|
||||
{
|
||||
Debug.Assert(ch < 0xFF, "Expecting ASCII character.");
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
//ASCII
|
||||
pDest[destOffset++] = ch;
|
||||
next += 2;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// possibly utf8 encoded sequence of unicode
|
||||
|
||||
// check if safe to unescape according to Iri rules
|
||||
|
||||
Debug.Assert(ch < 0xFF, "Expecting ASCII character.");
|
||||
|
||||
int startSeq = next;
|
||||
int byteCount = 1;
|
||||
// lazy initialization of max size, will reuse the array for next sequences
|
||||
if ((object)bytes == null)
|
||||
bytes = new byte[end - next];
|
||||
|
||||
bytes[0] = (byte)ch;
|
||||
next += 3;
|
||||
while (next < end)
|
||||
{
|
||||
// Check on exit criterion
|
||||
if ((ch = pInput[next]) != '%' || next + 2 >= end)
|
||||
break;
|
||||
|
||||
// already made sure we have 3 characters in str
|
||||
ch = UriHelper.EscapedAscii(pInput[next + 1], pInput[next + 2]);
|
||||
|
||||
//invalid hex sequence ?
|
||||
if (ch == Uri.c_DummyChar)
|
||||
break;
|
||||
// character is not part of a UTF-8 sequence ?
|
||||
else if (ch < '\x80')
|
||||
break;
|
||||
else
|
||||
{
|
||||
//a UTF-8 sequence
|
||||
bytes[byteCount++] = (byte)ch;
|
||||
next += 3;
|
||||
}
|
||||
|
||||
Debug.Assert(ch < 0xFF, "Expecting ASCII character.");
|
||||
}
|
||||
next--; // for loop will increment
|
||||
|
||||
|
||||
// Using encoder with no replacement fall-back will skip all invalid UTF-8 sequences.
|
||||
Encoding noFallbackCharUTF8 = Encoding.GetEncoding(
|
||||
Encoding.UTF8.CodePage,
|
||||
new EncoderReplacementFallback(""),
|
||||
new DecoderReplacementFallback(""));
|
||||
|
||||
char[] unescapedChars = new char[bytes.Length];
|
||||
int charCount = noFallbackCharUTF8.GetChars(bytes, 0, byteCount, unescapedChars, 0);
|
||||
|
||||
|
||||
if (charCount != 0)
|
||||
{
|
||||
// If invalid sequences were present in the original escaped string, we need to
|
||||
// copy the escaped versions of those sequences.
|
||||
// Decoded Unicode values will be kept only when they are allowed by the URI/IRI RFC
|
||||
// rules.
|
||||
UriHelper.MatchUTF8Sequence(pDest, dest, ref destOffset, unescapedChars, charCount, bytes,
|
||||
byteCount, component == UriComponents.Query, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// copy escaped sequence as is
|
||||
for (int i = startSeq; i <= next; ++i)
|
||||
{
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
pDest[destOffset++] = pInput[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
pDest[destOffset++] = pInput[next];
|
||||
}
|
||||
}
|
||||
else if (ch > '\x7f')
|
||||
{
|
||||
// unicode
|
||||
|
||||
char ch2;
|
||||
|
||||
if ((char.IsHighSurrogate(ch)) && (next + 1 < end))
|
||||
{
|
||||
ch2 = pInput[next + 1];
|
||||
escape = !CheckIriUnicodeRange(ch, ch2, ref surrogatePair, component == UriComponents.Query);
|
||||
if (!escape)
|
||||
{
|
||||
// copy the two chars
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
pDest[destOffset++] = pInput[next++];
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
pDest[destOffset++] = pInput[next];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckIriUnicodeRange(ch, component == UriComponents.Query))
|
||||
{
|
||||
if (!UriHelper.IsBidiControlCharacter(ch))
|
||||
{
|
||||
// copy it
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
pDest[destOffset++] = pInput[next];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// escape it
|
||||
escape = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// just copy the character
|
||||
Debug.Assert(dest.Length > destOffset, "Destination length exceeded destination offset.");
|
||||
pDest[destOffset++] = pInput[next];
|
||||
}
|
||||
|
||||
if (escape)
|
||||
{
|
||||
const int maxNumberOfBytesEncoded = 4;
|
||||
|
||||
if (bufferRemaining < maxNumberOfBytesEncoded * percentEncodingLen)
|
||||
{
|
||||
int newBufferLength = 0;
|
||||
|
||||
checked
|
||||
{
|
||||
// may need more memory since we didn't anticipate escaping
|
||||
newBufferLength = dest.Length + bufferCapacityIncrease;
|
||||
bufferRemaining += bufferCapacityIncrease;
|
||||
}
|
||||
|
||||
char[] newDest = new char[newBufferLength];
|
||||
|
||||
fixed (char* pNewDest = newDest)
|
||||
{
|
||||
Buffer.MemoryCopy((byte*)pDest, (byte*)pNewDest, newBufferLength * sizeof(char), destOffset * sizeof(char));
|
||||
}
|
||||
|
||||
if (destHandle.IsAllocated)
|
||||
{
|
||||
destHandle.Free();
|
||||
}
|
||||
|
||||
dest = newDest;
|
||||
|
||||
// re-pin new dest[] array
|
||||
destHandle = GCHandle.Alloc(dest, GCHandleType.Pinned);
|
||||
pDest = (char*)destHandle.AddrOfPinnedObject();
|
||||
}
|
||||
|
||||
byte[] encodedBytes = new byte[maxNumberOfBytesEncoded];
|
||||
fixed (byte* pEncodedBytes = encodedBytes)
|
||||
{
|
||||
int encodedBytesCount = Encoding.UTF8.GetBytes(pInput + next, surrogatePair ? 2 : 1, pEncodedBytes, maxNumberOfBytesEncoded);
|
||||
Debug.Assert(encodedBytesCount <= maxNumberOfBytesEncoded, "UTF8 encoder should not exceed specified byteCount");
|
||||
|
||||
bufferRemaining -= encodedBytesCount * percentEncodingLen;
|
||||
|
||||
for (int count = 0; count < encodedBytesCount; ++count)
|
||||
{
|
||||
UriHelper.EscapeAsciiChar((char)encodedBytes[count], dest, ref destOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (destHandle.IsAllocated)
|
||||
destHandle.Free();
|
||||
|
||||
Debug.Assert(destOffset <= dest.Length, "Destination length met or exceeded destination offset.");
|
||||
return new string(dest, 0, destOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
131
external/corefx/src/System.Private.Uri/src/System/UncNameHelper.cs
vendored
Normal file
131
external/corefx/src/System.Private.Uri/src/System/UncNameHelper.cs
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Globalization;
|
||||
|
||||
namespace System
|
||||
{
|
||||
// The class designed as to keep minimal the working set of Uri class.
|
||||
// The idea is to stay with static helper methods and strings
|
||||
internal class UncNameHelper
|
||||
{
|
||||
// fields
|
||||
|
||||
internal const int MaximumInternetNameLength = 256;
|
||||
|
||||
private UncNameHelper()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// properties
|
||||
|
||||
// methods
|
||||
internal static string ParseCanonicalName(string str, int start, int end, ref bool loopback)
|
||||
{
|
||||
return DomainNameHelper.ParseCanonicalName(str, start, end, ref loopback);
|
||||
}
|
||||
|
||||
//
|
||||
// IsValid
|
||||
//
|
||||
//
|
||||
// ATTN: This class has been re-designed as to conform to XP+ UNC hostname format
|
||||
// It is now similar to DNS name but can contain Unicode characters as well
|
||||
// This class will be removed and replaced by IDN specification later,
|
||||
// but for now we violate URI RFC cause we never escape Unicode characters on the wire
|
||||
// For the same reason we never unescape UNC host names since we never accept
|
||||
// them in escaped format.
|
||||
//
|
||||
//
|
||||
// Valid UNC server name chars:
|
||||
// a Unicode Letter (not allowed as the only in a segment)
|
||||
// a Latin-1 digit
|
||||
// '-' 45 0x2D
|
||||
// '.' 46 0x2E (only as a host domain delimiter)
|
||||
// '_' 95 0x5F
|
||||
//
|
||||
//
|
||||
// Assumption is the caller will check on the resulting name length
|
||||
// Remarks: MUST NOT be used unless all input indexes are verified and trusted.
|
||||
internal static unsafe bool IsValid(char* name, ushort start, ref int returnedEnd, bool notImplicitFile)
|
||||
{
|
||||
ushort end = (ushort)returnedEnd;
|
||||
|
||||
if (start == end)
|
||||
return false;
|
||||
//
|
||||
// First segment could consist of only '_' or '-' but it cannot be all digits or empty
|
||||
//
|
||||
bool validShortName = false;
|
||||
ushort i = start;
|
||||
for (; i < end; ++i)
|
||||
{
|
||||
if (name[i] == '/' || name[i] == '\\' || (notImplicitFile && (name[i] == ':' || name[i] == '?' || name[i] == '#')))
|
||||
{
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
else if (name[i] == '.')
|
||||
{
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
if (char.IsLetter(name[i]) || name[i] == '-' || name[i] == '_')
|
||||
{
|
||||
validShortName = true;
|
||||
}
|
||||
else if (name[i] < '0' || name[i] > '9')
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!validShortName)
|
||||
return false;
|
||||
|
||||
//
|
||||
// Subsequent segments must start with a letter or a digit
|
||||
//
|
||||
|
||||
for (; i < end; ++i)
|
||||
{
|
||||
if (name[i] == '/' || name[i] == '\\' || (notImplicitFile && (name[i] == ':' || name[i] == '?' || name[i] == '#')))
|
||||
{
|
||||
end = i;
|
||||
break;
|
||||
}
|
||||
else if (name[i] == '.')
|
||||
{
|
||||
if (!validShortName || ((i - 1) >= start && name[i - 1] == '.'))
|
||||
return false;
|
||||
|
||||
validShortName = false;
|
||||
}
|
||||
else if (name[i] == '-' || name[i] == '_')
|
||||
{
|
||||
if (!validShortName)
|
||||
return false;
|
||||
}
|
||||
else if (char.IsLetter(name[i]) || (name[i] >= '0' && name[i] <= '9'))
|
||||
{
|
||||
if (!validShortName)
|
||||
validShortName = true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// last segment can end with the dot
|
||||
if (((i - 1) >= start && name[i - 1] == '.'))
|
||||
validShortName = true;
|
||||
|
||||
if (!validShortName)
|
||||
return false;
|
||||
|
||||
// caller must check for (end - start <= MaximumInternetNameLength)
|
||||
|
||||
returnedEnd = end;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
external/corefx/src/System.Private.Uri/src/System/Uri.cs.REMOVED.git-id
vendored
Normal file
1
external/corefx/src/System.Private.Uri/src/System/Uri.cs.REMOVED.git-id
vendored
Normal file
@@ -0,0 +1 @@
|
||||
0b49658d660601699459d11db88cdb4e5b40e696
|
||||
425
external/corefx/src/System.Private.Uri/src/System/UriBuilder.cs
vendored
Normal file
425
external/corefx/src/System.Private.Uri/src/System/UriBuilder.cs
vendored
Normal file
@@ -0,0 +1,425 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
|
||||
namespace System
|
||||
{
|
||||
public class UriBuilder
|
||||
{
|
||||
// fields
|
||||
|
||||
private bool _changed = true;
|
||||
private string _fragment = string.Empty;
|
||||
private string _host = "localhost";
|
||||
private string _password = string.Empty;
|
||||
private string _path = "/";
|
||||
private int _port = -1;
|
||||
private string _query = string.Empty;
|
||||
private string _scheme = "http";
|
||||
private string _schemeDelimiter = Uri.SchemeDelimiter;
|
||||
private Uri _uri;
|
||||
private string _username = string.Empty;
|
||||
|
||||
// constructors
|
||||
|
||||
public UriBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
public UriBuilder(string uri)
|
||||
{
|
||||
// setting allowRelative=true for a string like www.acme.org
|
||||
Uri tryUri = new Uri(uri, UriKind.RelativeOrAbsolute);
|
||||
|
||||
if (tryUri.IsAbsoluteUri)
|
||||
{
|
||||
Init(tryUri);
|
||||
}
|
||||
else
|
||||
{
|
||||
uri = Uri.UriSchemeHttp + Uri.SchemeDelimiter + uri;
|
||||
Init(new Uri(uri));
|
||||
}
|
||||
}
|
||||
|
||||
public UriBuilder(Uri uri)
|
||||
{
|
||||
if ((object)uri == null)
|
||||
throw new ArgumentNullException(nameof(uri));
|
||||
|
||||
Init(uri);
|
||||
}
|
||||
|
||||
private void Init(Uri uri)
|
||||
{
|
||||
_fragment = uri.Fragment;
|
||||
_query = uri.Query;
|
||||
_host = uri.Host;
|
||||
_path = uri.AbsolutePath;
|
||||
_port = uri.Port;
|
||||
_scheme = uri.Scheme;
|
||||
_schemeDelimiter = uri.HasAuthority ? Uri.SchemeDelimiter : ":";
|
||||
|
||||
string userInfo = uri.UserInfo;
|
||||
|
||||
if (!string.IsNullOrEmpty(userInfo))
|
||||
{
|
||||
int index = userInfo.IndexOf(':');
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
_password = userInfo.Substring(index + 1);
|
||||
_username = userInfo.Substring(0, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
_username = userInfo;
|
||||
}
|
||||
}
|
||||
SetFieldsFromUri(uri);
|
||||
}
|
||||
|
||||
public UriBuilder(string schemeName, string hostName)
|
||||
{
|
||||
Scheme = schemeName;
|
||||
Host = hostName;
|
||||
}
|
||||
|
||||
public UriBuilder(string scheme, string host, int portNumber) : this(scheme, host)
|
||||
{
|
||||
Port = portNumber;
|
||||
}
|
||||
|
||||
public UriBuilder(string scheme,
|
||||
string host,
|
||||
int port,
|
||||
string pathValue
|
||||
) : this(scheme, host, port)
|
||||
{
|
||||
Path = pathValue;
|
||||
}
|
||||
|
||||
public UriBuilder(string scheme,
|
||||
string host,
|
||||
int port,
|
||||
string path,
|
||||
string extraValue
|
||||
) : this(scheme, host, port, path)
|
||||
{
|
||||
try
|
||||
{
|
||||
Extra = extraValue;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (exception is OutOfMemoryException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
throw new ArgumentException(SR.Argument_ExtraNotValid, nameof(extraValue));
|
||||
}
|
||||
}
|
||||
|
||||
// properties
|
||||
|
||||
private string Extra
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = string.Empty;
|
||||
}
|
||||
if (value.Length > 0)
|
||||
{
|
||||
if (value[0] == '#')
|
||||
{
|
||||
Fragment = value.Substring(1);
|
||||
}
|
||||
else if (value[0] == '?')
|
||||
{
|
||||
int end = value.IndexOf('#');
|
||||
if (end == -1)
|
||||
{
|
||||
end = value.Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
Fragment = value.Substring(end + 1);
|
||||
}
|
||||
Query = value.Substring(1, end - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException(SR.Argument_ExtraNotValid, nameof(value));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Fragment = string.Empty;
|
||||
Query = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Fragment
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fragment;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = string.Empty;
|
||||
}
|
||||
if (value.Length > 0 && value[0] != '#')
|
||||
{
|
||||
value = '#' + value;
|
||||
}
|
||||
_fragment = value;
|
||||
_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Host
|
||||
{
|
||||
get
|
||||
{
|
||||
return _host;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = string.Empty;
|
||||
}
|
||||
_host = value;
|
||||
//probable ipv6 address - Note: this is only supported for cases where the authority is inet-based.
|
||||
if (_host.IndexOf(':') >= 0)
|
||||
{
|
||||
//set brackets
|
||||
if (_host[0] != '[')
|
||||
_host = "[" + _host + "]";
|
||||
}
|
||||
_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return _password;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = string.Empty;
|
||||
}
|
||||
_password = value;
|
||||
_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
return _path;
|
||||
}
|
||||
set
|
||||
{
|
||||
if ((value == null) || (value.Length == 0))
|
||||
{
|
||||
value = "/";
|
||||
}
|
||||
_path = Uri.InternalEscapeString(value.Replace('\\', '/'));
|
||||
_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int Port
|
||||
{
|
||||
get
|
||||
{
|
||||
return _port;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < -1 || value > 0xFFFF)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(value));
|
||||
}
|
||||
_port = value;
|
||||
_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Query
|
||||
{
|
||||
get
|
||||
{
|
||||
return _query;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = string.Empty;
|
||||
}
|
||||
if (value.Length > 0 && value[0] != '?')
|
||||
{
|
||||
value = '?' + value;
|
||||
}
|
||||
_query = value;
|
||||
_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Scheme
|
||||
{
|
||||
get
|
||||
{
|
||||
return _scheme;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = string.Empty;
|
||||
}
|
||||
|
||||
int index = value.IndexOf(':');
|
||||
if (index != -1)
|
||||
{
|
||||
value = value.Substring(0, index);
|
||||
}
|
||||
|
||||
if (value.Length != 0)
|
||||
{
|
||||
if (!Uri.CheckSchemeName(value))
|
||||
{
|
||||
throw new ArgumentException(SR.net_uri_BadScheme, nameof(value));
|
||||
}
|
||||
value = value.ToLowerInvariant();
|
||||
}
|
||||
_scheme = value;
|
||||
_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public Uri Uri
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_changed)
|
||||
{
|
||||
_uri = new Uri(ToString());
|
||||
SetFieldsFromUri(_uri);
|
||||
_changed = false;
|
||||
}
|
||||
return _uri;
|
||||
}
|
||||
}
|
||||
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _username;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
value = string.Empty;
|
||||
}
|
||||
_username = value;
|
||||
_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// methods
|
||||
|
||||
public override bool Equals(object rparam)
|
||||
{
|
||||
if (rparam == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Uri.Equals(rparam.ToString());
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Uri.GetHashCode();
|
||||
}
|
||||
|
||||
private void SetFieldsFromUri(Uri uri)
|
||||
{
|
||||
_fragment = uri.Fragment;
|
||||
_query = uri.Query;
|
||||
_host = uri.Host;
|
||||
_path = uri.AbsolutePath;
|
||||
_port = uri.Port;
|
||||
_scheme = uri.Scheme;
|
||||
_schemeDelimiter = uri.HasAuthority ? Uri.SchemeDelimiter : ":";
|
||||
|
||||
string userInfo = uri.UserInfo;
|
||||
|
||||
if (userInfo.Length > 0)
|
||||
{
|
||||
int index = userInfo.IndexOf(':');
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
_password = userInfo.Substring(index + 1);
|
||||
_username = userInfo.Substring(0, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
_username = userInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (_username.Length == 0 && _password.Length > 0)
|
||||
{
|
||||
throw new UriFormatException(SR.net_uri_BadUserPassword);
|
||||
}
|
||||
|
||||
if (_scheme.Length != 0)
|
||||
{
|
||||
UriParser syntax = UriParser.GetSyntax(_scheme);
|
||||
if (syntax != null)
|
||||
_schemeDelimiter = syntax.InFact(UriSyntaxFlags.MustHaveAuthority) ||
|
||||
(_host.Length != 0 && syntax.NotAny(UriSyntaxFlags.MailToLikeUri) && syntax.InFact(UriSyntaxFlags.OptionalAuthority))
|
||||
? Uri.SchemeDelimiter
|
||||
: ":";
|
||||
else
|
||||
_schemeDelimiter = _host.Length != 0 ? Uri.SchemeDelimiter : ":";
|
||||
}
|
||||
|
||||
string result = _scheme.Length != 0 ? (_scheme + _schemeDelimiter) : string.Empty;
|
||||
return result
|
||||
+ _username
|
||||
+ ((_password.Length > 0) ? (":" + _password) : string.Empty)
|
||||
+ ((_username.Length > 0) ? "@" : string.Empty)
|
||||
+ _host
|
||||
+ (((_port != -1) && (_host.Length > 0)) ? (":" + _port.ToString()) : string.Empty)
|
||||
+ (((_host.Length > 0) && (_path.Length != 0) && (_path[0] != '/')) ? "/" : string.Empty) + _path
|
||||
+ _query
|
||||
+ _fragment;
|
||||
}
|
||||
}
|
||||
}
|
||||
106
external/corefx/src/System.Private.Uri/src/System/UriEnumTypes.cs
vendored
Normal file
106
external/corefx/src/System.Private.Uri/src/System/UriEnumTypes.cs
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace System
|
||||
{
|
||||
// Used to control whether absolute or relative URIs are used
|
||||
public enum UriKind
|
||||
{
|
||||
RelativeOrAbsolute = 0,
|
||||
Absolute = 1,
|
||||
Relative = 2
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum UriComponents
|
||||
{
|
||||
// Generic parts.
|
||||
// ATTN: The values must stay in sync with Uri.Flags.xxxNotCanonical
|
||||
Scheme = 0x1,
|
||||
UserInfo = 0x2,
|
||||
Host = 0x4,
|
||||
Port = 0x8,
|
||||
Path = 0x10,
|
||||
Query = 0x20,
|
||||
Fragment = 0x40,
|
||||
|
||||
StrongPort = 0x80,
|
||||
NormalizedHost = 0x100,
|
||||
|
||||
// This will also return respective delimiters for scheme, userinfo or port
|
||||
// Valid only for a single component requests.
|
||||
KeepDelimiter = 0x40000000,
|
||||
|
||||
// This is used by GetObjectData and can also be used directly.
|
||||
// Works for both absolute and relative Uris
|
||||
SerializationInfoString = unchecked((int)0x80000000),
|
||||
|
||||
// Shortcuts for general cases
|
||||
AbsoluteUri = Scheme | UserInfo | Host | Port | Path | Query | Fragment,
|
||||
HostAndPort = Host | StrongPort, //includes port even if default
|
||||
StrongAuthority = UserInfo | Host | StrongPort, //includes port even if default
|
||||
SchemeAndServer = Scheme | Host | Port,
|
||||
HttpRequestUrl = Scheme | Host | Port | Path | Query,
|
||||
PathAndQuery = Path | Query,
|
||||
}
|
||||
public enum UriFormat
|
||||
{
|
||||
UriEscaped = 1,
|
||||
Unescaped = 2, // Completely unescaped.
|
||||
SafeUnescaped = 3 // Canonical unescaped. Allows same uri to be reconstructed from the output.
|
||||
// If the unescaped sequence results in a new escaped sequence, it will revert to the original sequence.
|
||||
|
||||
// This value is reserved for the default ToString() format that is historically none of the above.
|
||||
// V1ToStringUnescape = 0x7FFF
|
||||
}
|
||||
|
||||
// This is used to control when host names are converted to idn names and
|
||||
// vice versa
|
||||
internal enum UriIdnScope
|
||||
{
|
||||
None, // Never use Idn
|
||||
AllExceptIntranet, // Use Idn in Internet and not intranet
|
||||
All // Internet and intranet
|
||||
}
|
||||
|
||||
internal enum ParsingError
|
||||
{
|
||||
// looks good
|
||||
None = 0,
|
||||
|
||||
// These first errors indicate that the Uri cannot be absolute, but may be relative.
|
||||
BadFormat = 1,
|
||||
BadScheme = 2,
|
||||
BadAuthority = 3,
|
||||
EmptyUriString = 4,
|
||||
LastRelativeUriOkErrIndex = 4,
|
||||
|
||||
// All higher error values are fatal, indicating that neither an absolute or relative
|
||||
// Uri could be generated.
|
||||
SchemeLimit = 5,
|
||||
SizeLimit = 6,
|
||||
MustRootedPath = 7,
|
||||
|
||||
// derived class controlled
|
||||
BadHostName = 8,
|
||||
NonEmptyHost = 9, // unix only
|
||||
BadPort = 10,
|
||||
BadAuthorityTerminator = 11,
|
||||
|
||||
// The user requested only a relative Uri, but an absolute Uri was parsed.
|
||||
CannotCreateRelative = 12
|
||||
}
|
||||
|
||||
[Flags]
|
||||
internal enum UnescapeMode
|
||||
{
|
||||
CopyOnly = 0x0, // used for V1.0 ToString() compatibility mode only
|
||||
Escape = 0x1, // Only used by ImplicitFile, the string is already fully unescaped
|
||||
Unescape = 0x2, // Only used as V1.0 UserEscaped compatibility mode
|
||||
EscapeUnescape = Unescape | Escape, // does both escaping control+reserved and unescaping of safe characters
|
||||
V1ToStringFlag = 0x4, // Only used as V1.0 ToString() compatibility mode, assumes DontEscape level also
|
||||
UnescapeAll = 0x8, // just unescape everything, leave bad escaped sequences as is
|
||||
UnescapeAllOrThrow = 0x10 | UnescapeAll, // just unescape everything plus throw on bad escaped sequences
|
||||
}
|
||||
}
|
||||
937
external/corefx/src/System.Private.Uri/src/System/UriExt.cs
vendored
Normal file
937
external/corefx/src/System.Private.Uri/src/System/UriExt.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
43
external/corefx/src/System.Private.Uri/src/System/UriFormatException.cs
vendored
Normal file
43
external/corefx/src/System.Private.Uri/src/System/UriFormatException.cs
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
#if netstandard10
|
||||
using System.Runtime.Serialization;
|
||||
#endif //netstandard10
|
||||
|
||||
namespace System
|
||||
{
|
||||
/// <summary>
|
||||
/// An exception class used when an invalid Uniform Resource Identifier is detected.
|
||||
/// </summary>
|
||||
#if netstandard10
|
||||
[Serializable]
|
||||
#endif //netstandard10
|
||||
public class UriFormatException : FormatException
|
||||
#if netstandard10
|
||||
, ISerializable
|
||||
#endif //netstandard10
|
||||
{
|
||||
public UriFormatException() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public UriFormatException(string textString) : base(textString)
|
||||
{
|
||||
}
|
||||
|
||||
public UriFormatException(string textString, Exception e) : base(textString, e)
|
||||
{
|
||||
}
|
||||
#if netstandard10
|
||||
protected UriFormatException(SerializationInfo serializationInfo, StreamingContext streamingContext) : base(serializationInfo, streamingContext)
|
||||
{
|
||||
}
|
||||
|
||||
void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext) {
|
||||
base.GetObjectData(serializationInfo, streamingContext);
|
||||
}
|
||||
#endif //netstandard10
|
||||
}; // class UriFormatException
|
||||
} // namespace System
|
||||
813
external/corefx/src/System.Private.Uri/src/System/UriHelper.cs
vendored
Normal file
813
external/corefx/src/System.Private.Uri/src/System/UriHelper.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
15
external/corefx/src/System.Private.Uri/src/System/UriHostNameType.cs
vendored
Normal file
15
external/corefx/src/System.Private.Uri/src/System/UriHostNameType.cs
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace System
|
||||
{
|
||||
public enum UriHostNameType
|
||||
{
|
||||
Unknown,
|
||||
Basic,
|
||||
Dns,
|
||||
IPv4,
|
||||
IPv6
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user