Allow . as hostname in pipe names#17284
Conversation
| } | ||
|
|
||
| string[] absolutePathParts = uri.AbsolutePath.Split(ForwardSlashSeparator); | ||
| string host = tokensByBackSlash[2]; |
There was a problem hiding this comment.
Can we do string host = tokensByBackSlash[2].Trim();?
There was a problem hiding this comment.
No. Np:\.\pipe\sql\query would lead to a successful connection but np:\. \pipe\sql\query doesn't lead to a successful connection in Native SNI.
We shouldnt trim the pipe parts.
| // Another valid Sql named pipe for an named instance is \\.\pipe\MSSQL$MYINSTANCE\sql\query | ||
| if (absolutePathParts.Length < 4) | ||
| //Check if the "pipe" keyword is the first part of path | ||
| if (!PipeToken.Equals(tokensByBackSlash[3])) |
There was a problem hiding this comment.
also if (!PipeToken.Equals(tokensByBackSlash[3].Trim()))?
There was a problem hiding this comment.
No trimming of pipe paths.
|
|
||
| for ( int i = 4; i < tokensByBackSlash.Length-1; i++) | ||
| { | ||
| pipeNameBuilder.Append(tokensByBackSlash[i]); |
There was a problem hiding this comment.
Can we do pipeNameBuilder.Append(tokensByBackSlash[i].Trim()); ?
| pipeNameBuilder.Append(Path.PathSeparator); | ||
| } | ||
| // Append the last part without a "/" | ||
| pipeNameBuilder.Append(tokensByBackSlash[tokensByBackSlash.Length - 1]); |
There was a problem hiding this comment.
What if connection string is \\.\pipe\sql\query\ ?
There was a problem hiding this comment.
SqlClient should fail to connect in this case.
With the change above a blank will be appended after the last \ and there will be a failure to connect
| ReportSNIError(SNIProviders.NP_PROV); | ||
| return false; | ||
| } | ||
|
|
There was a problem hiding this comment.
Check for leading backslashes?
There was a problem hiding this comment.
Disregard this, there's a check for it higher up.
* Use ROSpan.IndexOf as the workhorse for string.IndexOf * Make changes to Span.IndexOf to follow what string.IndexOf did. * Address PR feedback. * Use Unsafe.Read instead of Unsafe.ReadUnaligned. * Remove special casing for count == 0 * Fix up debug assert to use vector count instead of intptr.size * Use size of Vector<ushort> instead of Vector<byte>.Count Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
* Use ROSpan.IndexOf as the workhorse for string.IndexOf * Make changes to Span.IndexOf to follow what string.IndexOf did. * Address PR feedback. * Use Unsafe.Read instead of Unsafe.ReadUnaligned. * Remove special casing for count == 0 * Fix up debug assert to use vector count instead of intptr.size * Use size of Vector<ushort> instead of Vector<byte>.Count Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
* Use ROSpan.IndexOf as the workhorse for string.IndexOf * Make changes to Span.IndexOf to follow what string.IndexOf did. * Address PR feedback. * Use Unsafe.Read instead of Unsafe.ReadUnaligned. * Remove special casing for count == 0 * Fix up debug assert to use vector count instead of intptr.size * Use size of Vector<ushort> instead of Vector<byte>.Count Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
* Use ROSpan.IndexOf as the workhorse for string.IndexOf * Make changes to Span.IndexOf to follow what string.IndexOf did. * Address PR feedback. * Use Unsafe.Read instead of Unsafe.ReadUnaligned. * Remove special casing for count == 0 * Fix up debug assert to use vector count instead of intptr.size * Use size of Vector<ushort> instead of Vector<byte>.Count Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
* Use ROSpan.IndexOf as the workhorse for string.IndexOf * Make changes to Span.IndexOf to follow what string.IndexOf did. * Address PR feedback. * Use Unsafe.Read instead of Unsafe.ReadUnaligned. * Remove special casing for count == 0 * Fix up debug assert to use vector count instead of intptr.size * Use size of Vector<ushort> instead of Vector<byte>.Count Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Fixes https://github.com/dotnet/corefx/issues/17282
Since Uri cannot handle . as hostname, the changes include splitting the named pipe data source by \ and generating the hostname and pipename from the split parts.
Apart from the tests added, I ran some tests with a SqlServer to see if the connectivity works.
cc @corivera @geleems