-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Use IndexOfAny in HttpListener.HandleAuthentication #71137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -803,13 +803,10 @@ public HttpListenerContext EndGetContext(IAsyncResult asyncResult) | |
| if (authorizationHeader != null && (authenticationScheme & ~AuthenticationSchemes.Anonymous) != AuthenticationSchemes.None) | ||
| { | ||
| // Find the end of the scheme name. Trust that HTTP.SYS parsed out just our header ok. | ||
| for (index = 0; index < authorizationHeader.Length; index++) | ||
| index = authorizationHeader.AsSpan().IndexOfAny(" \t\r\n"); | ||
| if (index < 0) | ||
| { | ||
| if (authorizationHeader[index] == ' ' || authorizationHeader[index] == '\t' || | ||
| authorizationHeader[index] == '\r' || authorizationHeader[index] == '\n') | ||
| { | ||
| break; | ||
| } | ||
| index = authorizationHeader.Length; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will work. But I think this is only used in the condition bellow to guard if any character was found. e.g. you can simplify that without assignment as - if (index < authorizationHeader.Length)
+ if (index >= 0)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I missed that reading it on GH. However, without going to the first block, headerScheme should remain |
||
| } | ||
|
|
||
| // Currently only allow one Authorization scheme/header per request. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.