You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Uri] Uri(String, UriKind) throws IndexOutOfRangeException for certain inputs #1487
@davkean none of these throw anything (including UFE) on Desktop for me..?
Clearly this isa bug though as they throw IOORE on Core.
Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Uri.CreateUriInfo(Flags cF)
at System.Uri.EnsureUriInfo()
at System.Uri.ParseRemaining()
at System.Uri.EnsureParseRemaining()
at System.Uri.InitializeUri(ParsingError err, UriKind uriKind, UriFormatException& e)
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at ConsoleApp1.Program.Main(String[] args) in C:\dotnet\1\Program.cs:line 13
@karelz is this the right label for Uri? Please consider whether this is a 2.0 issue.
@danmosemsft Are you testing under 4.5+? Uri was changed in 4.5. I just verified and they all repro for me under desktop.
@Priya91 TBH, I've not done the legwork to figure out if they are invalid according to spec - they were generated for me by Pex. I don't need them for 2.0.
It looks like all of these are failing because they contain the Unicode LTR control character. Historically we have stripped control characters out of URIs, and that behavior is causing the issue here. We calculate the index of the end of the path and then strip out the control character, shortening the string and causing the index to fall beyond the end of the string.
The fix here is non-trivial, as the change will have to be made to some fairly complex unsafe code. I'll keep the issue assigned to me but don't have an ETA on this.
changed the title [-]Uri(String, UriKind) throws IndexOutOfRangeException for certain inputs[/-][+][Uri] Uri(String, UriKind) throws IndexOutOfRangeException for certain inputs[/+]on May 2, 2018
This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.
Activity
danmoseley commentedon Jun 19, 2017
@davkean none of these throw anything (including UFE) on Desktop for me..?
Clearly this isa bug though as they throw IOORE on Core.
@karelz is this the right label for Uri? Please consider whether this is a 2.0 issue.
danmoseley commentedon Jun 19, 2017
@Priya91 fyi
danmoseley commentedon Jun 19, 2017
My guess: these are not mainstream enough cases to churn Uri further for 2.0.
karelz commentedon Jun 19, 2017
It's a good label. @Priya91 can you please help with this one?
Priya91 commentedon Jun 19, 2017
@davkean These are invalid URIs? Will look into this.
davkean commentedon Jun 19, 2017
@danmosemsft Are you testing under 4.5+? Uri was changed in 4.5. I just verified and they all repro for me under desktop.
@Priya91 TBH, I've not done the legwork to figure out if they are invalid according to spec - they were generated for me by Pex. I don't need them for 2.0.
danmoseley commentedon Jun 19, 2017
@davkean ah, no I used csc out of the v4.0 folder...
davkean commentedon Jun 19, 2017
Yeah, you'll go down the 4.0 path.
karelz commentedon Jun 22, 2017
Does not look like 2.0 bug, moving to Future for further consideration.
rmkerr commentedon May 2, 2018
It looks like all of these are failing because they contain the Unicode LTR control character. Historically we have stripped control characters out of URIs, and that behavior is causing the issue here. We calculate the index of the end of the path and then strip out the control character, shortening the string and causing the index to fall beyond the end of the string.
The fix here is non-trivial, as the change will have to be made to some fairly complex unsafe code. I'll keep the issue assigned to me but don't have an ETA on this.
[-]Uri(String, UriKind) throws IndexOutOfRangeException for certain inputs[/-][+][Uri] Uri(String, UriKind) throws IndexOutOfRangeException for certain inputs[/+]davidsh commentedon Aug 28, 2019
As of .NET Core 3.0 Preview 8 these
are still throwing IndexOutOfRangeException. So, we still have a bug to fix.
12 remaining items
dotnet-policy-service commentedon Mar 5, 2025
This issue will now be closed since it had been marked
no-recent-activitybut received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.