Skip to content
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

ProductHeaderValue parser throws exception for empty values #10227

Closed
dsgouda opened this issue Aug 22, 2018 · 1 comment
Assignees

Comments

@dsgouda
Copy link

@dsgouda dsgouda commented Aug 22, 2018

Steps to Reproduce

  1. Create a project targeting .NET framework on a MacOS machine
  2. Use the snippet below to create a .cs file
  3. Restore, Build and run the exe using mono
using System.Net.Http;
            var pihv = new ProductInfoHeaderValue("OSNAME", "");
            System.Console.WriteLine(pihv.Product+"=>"+pihv.Comment);
            Console.ReadKey();

Current Behavior

The ProductHeaderValue ctor throws an exception in the parser an empty value is passed to it
The Exception comes from here

Expected Behavior

The ProductInfoHeaderValue object should be created successfully with an empty value. The same code on a windows implementation of System.Net.Http works as expected without throwing any exceptions

On which platforms did you notice this

[x] macOS
[ ] Linux
[ ] Windows

Version Used:

mono version:

Mono JIT compiler version 5.10.1.57 (2017-12/ea8a24b1bbf Tue Apr 24 14:53:01 EDT 2018)

Stacktrace

Unhandled Exception:
System.ArgumentException: Value does not fall within the expected range.
  at System.Net.Http.Headers.Parser+Token.Check (System.String s) [0x00019] in <424e46dead96486786256709cc4c63d9>:0 
  at System.Net.Http.Headers.ProductHeaderValue..ctor (System.String name, System.String version) [0x0000a] in <424e46dead96486786256709cc4c63d9>:0 
  at System.Net.Http.Headers.ProductInfoHeaderValue..ctor (System.String productName, System.String productVersion) [0x00006] in <424e46dead96486786256709cc4c63d9>:0 
  at sctest.Program.Main (System.String[] args) [0x00001] in <b76927fa3c6447ed98c8230a28e82d3b>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Value does not fall within the expected range.
  at System.Net.Http.Headers.Parser+Token.Check (System.String s) [0x00019] in <424e46dead96486786256709cc4c63d9>:0 
  at System.Net.Http.Headers.ProductHeaderValue..ctor (System.String name, System.String version) [0x0000a] in <424e46dead96486786256709cc4c63d9>:0 
  at System.Net.Http.Headers.ProductInfoHeaderValue..ctor (System.String productName, System.String productVersion) [0x00006] in <424e46dead96486786256709cc4c63d9>:0 
  at sctest.Program.Main (System.String[] args) [0x00001] in <b76927fa3c6447ed98c8230a28e82d3b>:0 
 

@dsgouda

This comment has been minimized.

Copy link
Author

@dsgouda dsgouda commented Aug 22, 2018

P.S.: This was discovered by an external user here

marek-safar added a commit to marek-safar/mono that referenced this issue Sep 7, 2018
@marek-safar marek-safar self-assigned this Sep 7, 2018
akoeplinger added a commit that referenced this issue Sep 7, 2018
monojenkins added a commit to monojenkins/mono that referenced this issue Sep 24, 2018
marek-safar added a commit that referenced this issue Sep 24, 2018
jonpryor added a commit to xamarin/xamarin-android that referenced this issue Dec 6, 2018
Bumps to mono/api-snapshot@b99fc87.
Bumps to mono/bockbuild@5af573e.
Bumps to mono/boringssl@41221b4.
Bumps to mono/corefx@23d0b58.
Bumps to mono/corert@af496fc.
Bumps to mono/linker@7af03ce.
Bumps to mono/NUnitLite@00e259a.
Bumps to mono/reference-assemblies@9325826.
Bumps to mono/roslyn-binaries@249709f.
Bumps to mono/xunit-binaries@bb58347.

	$ git diff --shortstat b63e5378..23f2024a      # mono 
	 1630 files changed, 50926 insertions(+), 92212 deletions(-)

Fixes: mono/mono#6352
Fixes: mono/mono#6947
Fixes: mono/mono#6992
Fixes: mono/mono#7615
Fixes: mono/mono#8340
Fixes: mono/mono#8407
Fixes: mono/mono#8575
Fixes: mono/mono#8627
Fixes: mono/mono#8707
Fixes: mono/mono#8766
Fixes: mono/mono#8848
Fixes: mono/mono#8866
Fixes: mono/mono#8935
Fixes: mono/mono#9010
Fixes: mono/mono#9023
Fixes: mono/mono#9031
Fixes: mono/mono#9033
Fixes: mono/mono#9106
Fixes: mono/mono#9109
Fixes: mono/mono#9155
Fixes: mono/mono#9179
Fixes: mono/mono#9232
Fixes: mono/mono#9234
Fixes: mono/mono#9262
Fixes: mono/mono#9277
Fixes: mono/mono#9292
Fixes: mono/mono#9318
Fixes: mono/mono#9318
Fixes: mono/mono#9332
Fixes: mono/mono#9407
Fixes: mono/mono#9421
Fixes: mono/mono#9505
Fixes: mono/mono#9542
Fixes: mono/mono#9581
Fixes: mono/mono#9623
Fixes: mono/mono#9684
Fixes: mono/mono#9750
Fixes: mono/mono#9753
Fixes: mono/mono#9772
Fixes: mono/mono#9839
Fixes: mono/mono#9869
Fixes: mono/mono#9921
Fixes: mono/mono#9943
Fixes: mono/mono#9947
Fixes: mono/mono#9973
Fixes: mono/mono#9996
Fixes: mono/mono#10000
Fixes: mono/mono#10031
Fixes: mono/mono#10035
Fixes: mono/mono#10227
Fixes: mono/mono#10243
Fixes: mono/mono#10303
Fixes: mono/mono#10448
Fixes: mono/mono#10483
Fixes: mono/mono#10488
Fixes: mono/mono#10863
Fixes: mono/mono#11123
Fixes: mono/mono#11138
Fixes? mono/mono#11146
Fixes: mono/mono#11202
Fixes: mono/mono#11378
Fixes: mono/mono#11479
Fixes: mono/mono#11613
Fixes: #1951
Fixes: xamarin/xamarin-macios#4347
Fixes: xamarin/xamarin-macios#4617
Fixes: xamarin/xamarin-macios#4984
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.