Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@wfurt
Copy link
Member

@wfurt wfurt commented Jul 20, 2018

Primarily covers 'http://10.30.62.64:7890/' accepted by curl.

Fixes #31326

@wfurt wfurt self-assigned this Jul 20, 2018
@wfurt
Copy link
Member Author

wfurt commented Jul 20, 2018

@dotnet-bot test Outerloop Windows x64 Debug Build
@dotnet-bot test Outerloop Linux x64 Debug Build
@dotnet-bot test Outerloop OSX x64 Debug Build

{
host = value.Substring(0, separatorIndex);
if (!ushort.TryParse(value.AsSpan(separatorIndex + 1), out port))
int endIndex = separatorIndex + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this string parsing code exist at all? Why not just convert the string to a URI and then extract the host and port portions of it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was like that at some point. It did not handle well cases when the value is for example just IP (or ip + port) The other issue was handling special characters in password. So we end up breaking it to fragments on our own.

host = value.Substring(0, separatorIndex);
if (!ushort.TryParse(value.AsSpan(separatorIndex + 1), out port))
int endIndex = separatorIndex + 1;
// Strip any trailing characters after port num,ber.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"num,ber" -> "number"

break;
}
endIndex += 1;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add newline after this brace.

// Strip any trailing characters after port num,ber.
while (endIndex < value.Length)
{
if (!char.IsDigit(value[endIndex]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that char.IsDigit returns true for things other than '0'-'9'. It may not matter here other than for very esoteric cases.

@davidsh davidsh merged commit 56d177d into dotnet:master Jul 21, 2018
@wfurt wfurt added this to the 2.1.x milestone Jul 24, 2018
@wfurt wfurt deleted the env_proxy branch July 24, 2018 16:19
@wfurt wfurt removed this from the 2.1.x milestone Jul 24, 2018
wfurt added a commit to wfurt/corefx that referenced this pull request Jul 24, 2018
wfurt added a commit to wfurt/corefx that referenced this pull request Jul 24, 2018
…dotnet#31232)

improve port parsing to be more resilient against trailing characters
@karelz karelz added this to the 3.0 milestone Jul 24, 2018
wfurt added a commit that referenced this pull request Aug 9, 2018
…#31232) (#31327)

improve port parsing to be more resilient against trailing characters
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…dotnet/corefx#31232)

improve port parsing to be more resilient against trailing characters


Commit migrated from dotnet/corefx@56d177d
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Product bug (most likely)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants