Skip to content

Commit 6bb647e

Browse files
authored
Merge pull request #62617 from vseanreesermsft/internal-merge-9.0-2025-07-08-1439
Merging internal commits for release/9.0
2 parents 3444eab + f432909 commit 6bb647e

File tree

10 files changed

+813
-756
lines changed

10 files changed

+813
-756
lines changed

NuGet.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
<clear />
55
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
66
<!-- Begin: Package sources from dotnet-runtime -->
7+
<add key="darc-int-dotnet-runtime-3c298d9" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-3c298d9f/nuget/v3/index.json" />
78
<!-- End: Package sources from dotnet-runtime -->
89
<!-- Begin: Package sources from dotnet-efcore -->
10+
<add key="darc-int-dotnet-efcore-67d253c" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-67d253c1/nuget/v3/index.json" />
911
<!-- End: Package sources from dotnet-efcore -->
1012
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
1113
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
@@ -28,8 +30,10 @@
2830
<clear />
2931
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
3032
<!-- Begin: Package sources from dotnet-efcore -->
33+
<add key="darc-int-dotnet-efcore-67d253c" value="true" />
3134
<!-- End: Package sources from dotnet-efcore -->
3235
<!-- Begin: Package sources from dotnet-runtime -->
36+
<add key="darc-int-dotnet-runtime-3c298d9" value="true" />
3337
<!-- End: Package sources from dotnet-runtime -->
3438
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
3539
</disabledPackageSources>

eng/Baseline.Designer.props

Lines changed: 388 additions & 388 deletions
Large diffs are not rendered by default.

eng/Baseline.xml

Lines changed: 106 additions & 106 deletions
Large diffs are not rendered by default.

eng/Version.Details.xml

Lines changed: 160 additions & 160 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 81 additions & 81 deletions
Large diffs are not rendered by default.

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "9.0.107"
3+
"version": "9.0.108"
44
},
55
"tools": {
6-
"dotnet": "9.0.107",
6+
"dotnet": "9.0.108",
77
"runtimes": {
88
"dotnet/x86": [
99
"$(MicrosoftNETCoreBrowserDebugHostTransportVersion)"

src/Http/Headers/test/CookieHeaderValueTest.cs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static TheoryData<string> InvalidCookieValues
7575
}
7676
}
7777

78-
public static TheoryData<IList<CookieHeaderValue>, string?[]> ListOfCookieHeaderDataSet
78+
public static TheoryData<IList<CookieHeaderValue>, string?[]> ListOfStrictCookieHeaderDataSet
7979
{
8080
get
8181
{
@@ -94,19 +94,30 @@ public static TheoryData<string> InvalidCookieValues
9494

9595
dataset.Add(new[] { header1 }.ToList(), new[] { string1 });
9696
dataset.Add(new[] { header1, header1 }.ToList(), new[] { string1, string1 });
97-
dataset.Add(new[] { header1, header1 }.ToList(), new[] { string1, null, "", " ", ";", " , ", string1 });
9897
dataset.Add(new[] { header2 }.ToList(), new[] { string2 });
9998
dataset.Add(new[] { header1, header2 }.ToList(), new[] { string1, string2 });
100-
dataset.Add(new[] { header1, header2 }.ToList(), new[] { string1 + ", " + string2 });
10199
dataset.Add(new[] { header2, header1 }.ToList(), new[] { string2 + "; " + string1 });
102100
dataset.Add(new[] { header1, header2, header3, header4 }.ToList(), new[] { string1, string2, string3, string4 });
103-
dataset.Add(new[] { header1, header2, header3, header4 }.ToList(), new[] { string.Join(",", string1, string2, string3, string4) });
104101
dataset.Add(new[] { header1, header2, header3, header4 }.ToList(), new[] { string.Join(";", string1, string2, string3, string4) });
105102

106103
return dataset;
107104
}
108105
}
109106

107+
public static TheoryData<IList<CookieHeaderValue>, string?[]> ListOfCookieHeaderDataSet
108+
{
109+
get
110+
{
111+
var header1 = new CookieHeaderValue("name1", "n1=v1&n2=v2&n3=v3");
112+
var string1 = "name1=n1=v1&n2=v2&n3=v3";
113+
114+
var dataset = new TheoryData<IList<CookieHeaderValue>, string?[]>();
115+
dataset.Concat(ListOfStrictCookieHeaderDataSet);
116+
dataset.Add(new[] { header1, header1 }.ToList(), new[] { string1, null, "", " ", ";", " , ", string1 });
117+
return dataset;
118+
}
119+
}
120+
110121
public static TheoryData<IList<CookieHeaderValue>?, string?[]> ListWithInvalidCookieHeaderDataSet
111122
{
112123
get
@@ -127,18 +138,19 @@ public static TheoryData<string> InvalidCookieValues
127138
dataset.Add(new[] { header1 }.ToList(), new[] { validString1, invalidString1 });
128139
dataset.Add(new[] { header1 }.ToList(), new[] { validString1, null, "", " ", ";", " , ", invalidString1 });
129140
dataset.Add(new[] { header1 }.ToList(), new[] { invalidString1, null, "", " ", ";", " , ", validString1 });
130-
dataset.Add(new[] { header1 }.ToList(), new[] { validString1 + ", " + invalidString1 });
131-
dataset.Add(new[] { header2 }.ToList(), new[] { invalidString1 + ", " + validString2 });
141+
dataset.Add(null, new[] { validString1 + ", " });
142+
dataset.Add(null, new[] { invalidString1 + ", " + validString2 });
132143
dataset.Add(new[] { header1 }.ToList(), new[] { invalidString1 + "; " + validString1 });
133144
dataset.Add(new[] { header2 }.ToList(), new[] { validString2 + "; " + invalidString1 });
134145
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { invalidString1, validString1, validString2, validString3 });
135146
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { validString1, invalidString1, validString2, validString3 });
136147
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { validString1, validString2, invalidString1, validString3 });
137148
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { validString1, validString2, validString3, invalidString1 });
138-
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { string.Join(",", invalidString1, validString1, validString2, validString3) });
139-
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { string.Join(",", validString1, invalidString1, validString2, validString3) });
140-
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { string.Join(",", validString1, validString2, invalidString1, validString3) });
141-
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { string.Join(",", validString1, validString2, validString3, invalidString1) });
149+
dataset.Add(null, new[] { string.Join(",", invalidString1, validString1, validString2, validString3) });
150+
dataset.Add(null, new[] { string.Join(",", validString1, invalidString1, validString2, validString3) });
151+
dataset.Add(null, new[] { string.Join(",", validString1, validString2, invalidString1, validString3) });
152+
dataset.Add(null, new[] { string.Join(",", validString1, validString2, validString3, invalidString1) });
153+
dataset.Add(null, new[] { string.Join(",", validString1, validString2, validString3) });
142154
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { string.Join(";", invalidString1, validString1, validString2, validString3) });
143155
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { string.Join(";", validString1, invalidString1, validString2, validString3) });
144156
dataset.Add(new[] { header1, header2, header3 }.ToList(), new[] { string.Join(";", validString1, validString2, invalidString1, validString3) });
@@ -248,7 +260,7 @@ public void CookieHeaderValue_ParseList_AcceptsValidValues(IList<CookieHeaderVal
248260
}
249261

250262
[Theory]
251-
[MemberData(nameof(ListOfCookieHeaderDataSet))]
263+
[MemberData(nameof(ListOfStrictCookieHeaderDataSet))]
252264
public void CookieHeaderValue_ParseStrictList_AcceptsValidValues(IList<CookieHeaderValue> cookies, string[] input)
253265
{
254266
var results = CookieHeaderValue.ParseStrictList(input);
@@ -267,7 +279,7 @@ public void CookieHeaderValue_TryParseList_AcceptsValidValues(IList<CookieHeader
267279
}
268280

269281
[Theory]
270-
[MemberData(nameof(ListOfCookieHeaderDataSet))]
282+
[MemberData(nameof(ListOfStrictCookieHeaderDataSet))]
271283
public void CookieHeaderValue_TryParseStrictList_AcceptsValidValues(IList<CookieHeaderValue> cookies, string[] input)
272284
{
273285
var result = CookieHeaderValue.TryParseStrictList(input, out var results);

src/Http/Http.Extensions/test/HeaderDictionaryTypeExtensionsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public void GetListT_StringWithQualityHeaderValidValue_Success()
214214
public void GetListT_CookieHeaderValue_Success()
215215
{
216216
var context = new DefaultHttpContext();
217-
context.Request.Headers.Cookie = "cookie1=a,cookie2=b";
217+
context.Request.Headers.Cookie = "cookie1=a;cookie2=b";
218218

219219
var result = context.Request.GetTypedHeaders().GetList<CookieHeaderValue>(HeaderNames.Cookie);
220220

src/Http/Http/test/RequestCookiesCollectionTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,18 @@ public void ParseManyCookies()
3333
[Theory]
3434
[InlineData(",", null)]
3535
[InlineData(";", null)]
36-
[InlineData("er=dd,cc,bb", new[] { "dd" })]
37-
[InlineData("er=dd,err=cc,errr=bb", new[] { "dd", "cc", "bb" })]
38-
[InlineData("errorcookie=dd,:(\"sa;", new[] { "dd" })]
36+
[InlineData("er=dd,cc,bb", null)]
37+
[InlineData("er=dd,err=cc,errr=bb", null)]
38+
[InlineData("errorcookie=dd,:(\"sa;", null)]
3939
[InlineData("s;", null)]
4040
[InlineData("er=;,err=,errr=\\,errrr=\"", null)]
41+
[InlineData("a@a=a;", null)]
42+
[InlineData("a@ a=a;", null)]
43+
[InlineData("a a=a;", null)]
44+
[InlineData(",a=a;", null)]
45+
[InlineData(",a=a", null)]
46+
[InlineData("a=a;,b=b", new []{ "a" })] // valid cookie followed by invalid cookie
47+
[InlineData(",a=a;b=b", new[] { "b" })] // invalid cookie followed by valid cookie
4148
public void ParseInvalidCookies(string cookieToParse, string[] expectedCookieValues)
4249
{
4350
var cookies = RequestCookieCollection.Parse(new StringValues(new[] { cookieToParse }));

src/Http/Shared/CookieHeaderParserShared.cs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ public static bool TryParseValue(StringSegment value, ref int index, bool suppor
8989

9090
if (!TryGetCookieLength(value, ref current, out parsedName, out parsedValue))
9191
{
92+
var separatorIndex = value.IndexOf(';', current);
93+
if (separatorIndex > 0)
94+
{
95+
// Skip the invalid values and keep trying.
96+
index = separatorIndex;
97+
}
98+
else
99+
{
100+
// No more separators, so we're done.
101+
index = value.Length;
102+
}
92103
return false;
93104
}
94105

@@ -97,6 +108,17 @@ public static bool TryParseValue(StringSegment value, ref int index, bool suppor
97108
// If we support multiple values and we've not reached the end of the string, then we must have a separator.
98109
if ((separatorFound && !supportsMultipleValues) || (!separatorFound && (current < value.Length)))
99110
{
111+
var separatorIndex = value.IndexOf(';', current);
112+
if (separatorIndex > 0)
113+
{
114+
// Skip the invalid values and keep trying.
115+
index = separatorIndex;
116+
}
117+
else
118+
{
119+
// No more separators, so we're done.
120+
index = value.Length;
121+
}
100122
return false;
101123
}
102124

@@ -112,7 +134,7 @@ private static int GetNextNonEmptyOrWhitespaceIndex(StringSegment input, int sta
112134
separatorFound = false;
113135
var current = startIndex + HttpRuleParser.GetWhitespaceLength(input, startIndex);
114136

115-
if ((current == input.Length) || (input[current] != ',' && input[current] != ';'))
137+
if (current == input.Length || input[current] != ';')
116138
{
117139
return current;
118140
}
@@ -125,8 +147,8 @@ private static int GetNextNonEmptyOrWhitespaceIndex(StringSegment input, int sta
125147

126148
if (skipEmptyValues)
127149
{
128-
// Most headers only split on ',', but cookies primarily split on ';'
129-
while ((current < input.Length) && ((input[current] == ',') || (input[current] == ';')))
150+
// Cookies are split on ';'
151+
while (current < input.Length && input[current] == ';')
130152
{
131153
current++; // skip delimiter.
132154
current = current + HttpRuleParser.GetWhitespaceLength(input, current);
@@ -136,6 +158,18 @@ private static int GetNextNonEmptyOrWhitespaceIndex(StringSegment input, int sta
136158
return current;
137159
}
138160

161+
/*
162+
* https://www.rfc-editor.org/rfc/rfc6265#section-4.1.1
163+
* cookie-pair = cookie-name "=" cookie-value
164+
* cookie-name = token
165+
* token = 1*<any CHAR except CTLs or separators>
166+
separators = "(" | ")" | "<" | ">" | "@"
167+
| "," | ";" | ":" | "\" | <">
168+
| "/" | "[" | "]" | "?" | "="
169+
| "{" | "}" | SP | HT
170+
CTL = <any US-ASCII control character
171+
(octets 0 - 31) and DEL (127)>
172+
*/
139173
// name=value; name="value"
140174
internal static bool TryGetCookieLength(StringSegment input, ref int offset, [NotNullWhen(true)] out StringSegment? parsedName, [NotNullWhen(true)] out StringSegment? parsedValue)
141175
{

0 commit comments

Comments
 (0)